This foreach loop creates about 120 table rows.
In every row there are two input fields where the user can update/change the first and last name.
After changing the input value, the user clicks on the "Save" button to send the input values with $_POST.
<table>
<? foreach ($members as $member) {?>
<form name="member" action="" method="POST">
<tr>
<td><input name="id" type="hidden" value="<? echo $member['id'] ?>"></td>
<td><input name="first_name" type="text" value="<? echo $member['first_name'] ?>"></td>
<td><input name="last_name" type="hidden" value="<? echo $member['last_name'] ?>"></td>
<td><input type="submit" value="Save"></td>
</tr>
</form>
<? } ?>
I see the problem, that there are 120 input fields with name="id"
and name="first_name"
and name="last_name"
.
Normaly I would take the submited value like this and but it into a variable:
$first_name = $_POST['first_name'];
Will the form
only submit the values inside the <form>
-tags where the submit button is located or is there another solution for preventing that values get mixed up between other forms?