I am having a problem with PHP3 and using hidden fields with the same name in multiple forms on a page. Whew!
For example, I may have 3 forms on a page. Form 1 might be like:
<form name="enterform" action="myscript.php3" method="POST">
<input type="text" name="mytext">
<input type="submit" name="GO">
</form>
Then, I might have a couple of other forms like:
<form name="nextform" action="myscript.php3" method="POST">
<input type="hidden" name="mytext" value="3">
<input type="submit" name="Next">
</form>
<form name="prevform" action="myscript.php3" method="POST">
<input type="hidden" name="mytext" value="2">
<input type="submit" name="Previous">
</form>
So, there are three forms, each with a field called "mytext". One of the mytext fields is a text box and the other instances of mytext are hidden fields (fixed values).
Here's my dilema. If I enter a value into the text box and click the submit button, I notice that the value of $mytext is whatever I entered into the text box. Great! But, if I click the submit button on either of the forms with the hidden mytext fields, the value of $mytext is always whatever it is defined as in the last form. So, in my example above, no matter if I click "Next" or "Previous", the value of $mytext will always be 2. If I switch nextform and prevform around, the value of $mytext will always be 3 whenever I click on the "Next" or "Previous" submit button. This leads me to believe that PHP is unable to differentiate hidden fields with the same name between multiple forms and just creates a bunch of variables, overwriting the old value when a new one comes up.
Am I correct on this? I realize I could find a different way to do my forms, but this way creates the cleanest code in the long run. Is there a way to get around this problem. All I want is the value of $mytext to be 2 when I click on the "Previous" button and 3 when I click on the "Next" button. Anyone with experience on this?
Thanks,
Scott Christensen