Php / html form adds extra values

Let's say I have the following, simple form that conveys the value of an input element:

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

How to send additional values ​​along with the value of the input field, for example, an arbitrary string or variable inside the current php script. I know this is possible with GET, but I need POST.

early.

+7
source share
3 answers

You can include a hidden form element.

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

You can just use the hidden field . For example:

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

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

+7
source

As already mentioned, using hidden input fields is an option, but you can also use session . Thus, you do not need to post anything, the variables remain on the server and are not displayed in html.

+4
source

All Articles