user3438904
user3438904

Reputation: 3

Multiple Forms in one page

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

Answers (2)

Hieu Le
Hieu Le

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

Tesserex
Tesserex

Reputation: 17314

You need to close your form tag with a </form> at the end of the loop.

Upvotes: 1

Related Questions