Reputation: 3
I have Multiple forms in one page (form is in loop) On submit $_POST is filled with last form elements How can i divide this forms?
P.S forms are exactly the same because they are in the loop only 1 parameter is different
Example:
<?php while ($row = $result->fetch_assoc()) { ?>
<form action="" method="POST">
<input type="hidden" name="id" value="<?php echo $row['id'] ?>">
<input type="submit" name="submit">
<?php
}
?>
Upvotes: 0
Views: 148
Reputation: 8415
You need to close each form.
<?php while ($row = $result->fetch_assoc()) { ?>
<form action="" method="POST">
<input type="hidden" name="id" value="<?php echo $row['id'] ?>">
<input type="submit" name="submit">
</form>
<?php
}
?>
Upvotes: 4
Reputation: 17314
You need to close your form tag with a </form>
at the end of the loop.
Upvotes: 1