php / html表单发布额外值

时间:2022-10-16 12:53:45

say i have the following, a simple form which passes the value of an inputbox element:

说我有以下,一个传递inputbox元素的值的简单形式:

 <form action="updaterow.php"metho="POST"> 
<input type="text" name="price" /> </form>

How can I post extra values along with the inputbox value, for example an arbitrary string or a variable inside the current php script. I know this is possible with GET but i need POST.

如何发布额外的值以及输入框值,例如当前php脚本中的任意字符串或变量。我知道GET可以实现,但我需要POST。

thanks in advance.

提前致谢。

3 个解决方案

#1


19  

You can include a hidden form element.

您可以包含隐藏的表单元素。

<input type="hidden" name="foo" value="bar" />

#2


7  

You can simply use a hidden field. Like so:

您只需使用隐藏字段即可。像这样:

<input type="hidden" name="your-field-name" value="your-field-value" />

This field will then be available in your PHP script as $_POST['your-field-name']

然后,您的PHP脚本中将显示此字段为$ _POST ['your-field-name']

#3


4  

As mentioned already, using hidden input fields is an option, but you can also use a session. That way you don´t have to post anything, the variables remain on the server and are not exposed in the html.

如前所述,使用隐藏输入字段是一个选项,但您也可以使用会话。这样您就不必发布任何内容,变量保留在服务器上,并且不会在html中公开。

#1


19  

You can include a hidden form element.

您可以包含隐藏的表单元素。

<input type="hidden" name="foo" value="bar" />

#2


7  

You can simply use a hidden field. Like so:

您只需使用隐藏字段即可。像这样:

<input type="hidden" name="your-field-name" value="your-field-value" />

This field will then be available in your PHP script as $_POST['your-field-name']

然后,您的PHP脚本中将显示此字段为$ _POST ['your-field-name']

#3


4  

As mentioned already, using hidden input fields is an option, but you can also use a session. That way you don´t have to post anything, the variables remain on the server and are not exposed in the html.

如前所述,使用隐藏输入字段是一个选项,但您也可以使用会话。这样您就不必发布任何内容,变量保留在服务器上,并且不会在html中公开。