I have 2 forms on one page. I have hidden variables in each form, with separate names, that contain values. The user decides which form to submit on. Only 1 form will be processed.
Now my problem is, when I read the Post Variables from the server side with PHP.
-
-
foreach($_POST as $name => $value) {
-
print "$name : $value<br>";
-
}
-
That code will output the hidden variables from both forms, rather than just the form the user submitted on respectively.
-
<form name = 'form0' method = 'POST' action='add.php'>
-
<input type = 'hidden' name='hItem0' value = 'test0'>;
-
<input type = 'submit' value = 'Add0'>
-
</form>
-
-
<form name = 'form1' method = 'POST' action='add.php'>
-
<input type = 'hidden' name='hItem1' value = 'test1'>;
-
<input type = 'submit' value = 'Add1'>
-
</form>
-
The output on add.php is test0 and test1, despite which form the user submitted on.
Someone care to shed some light?