the child-Elements of a form may have a name-property ( <input type="text" name="text1" /> ).
When the form is submitted all name/values-pairs of those elements will be sent to the webserver using the format according to the method/enctype - property of the form-element.
i.e.
Code: Select all
&lt;form method="get"&gt;
&lt;input type="hidden" name="itemId" value="8765" /&gt;
&lt;input type="text" name="comment" /&gt;
&lt;input type="radio" name="rating" value="nice" /&gt;
&lt;input type="radio" name="rating" value="fair" /&gt;
&lt;input type="radio" name="rating" value="bad" /&gt;
&lt;input type="submit" /&gt;
&lt;/form&gt;
when this form is submitted,
- itemId (=8765)
- comment (=what ever the user wrote into the field)
- rating (= the value of the radio-button the user chose)
will be sent
The method of the form-action is 'get'. So in your php-script the parameters will be accessable through the superglobal array
$_GET ( $_GET['itemId'], $_GET['comment'] & $_GET['rating'] )
if method would've been 'post' they had been stored in the
$_POST array.
$_REQUEST contains all the parameter wether they were sent by 'get' or 'post'
You may also name the submit-button (<input type="submit" name="submit" value="itemDesc">) to identify the form-request
Code: Select all
...if (array_key_exists('submit', $_REQUEST))
handleRequest();
else
printForm();
...
these arrays have been introduced with php 4.1. If you're using an older version take a look at the notes in the reference