且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在php中保留下拉框的值

更新时间:2023-02-24 22:10:52

执行此操作的方法有很多,区别在于您希望存储的深度.在不浪费太多时间的情况下,以下是存储选项的快速列表:

There are many ways to do this, the differences come down to how 'deep' you want the storage to be. Without wasting too much time here is a quick list of storage options:

  • POST vars(这是最适合您的情况的解决方案)
  • 饼干
  • 会话
  • 数据库
  • 服务器文件系统
  • 等等等

基本上,最简单的技术是获取传递的数据并重新显示,因此对于您的表单,您有2个输入, leftval & rightval ,用户点击表单上的Submit,然后将它们相乘以显示结果.

Basically the simplest technique is to take the data that is passed and redisplay it, so for your form you have 2 inputs, leftval & rightval, the user hits submit on the form and you multiply them to show the result.

构建页面以显示结果时,请使用$ _POST ['leftval']&$ _POST ['rigtval']将其填充到新页面上.确保对这些值进行清理,并在退出过程中将其转义!

When you build the page to show the result use the $_POST['leftval'] & $_POST['rigtval'] to populate them on the new page. Make sure to sanitize the values and escape them on the way out!