Jump to content

[SOLVED] 2+ forms on 1 page, id set to the bottem form for all?


Michdd

Recommended Posts

I have forms that are automatically generated and have a field automatically generated called 'id' (hidden field) now I was having a problem with the forms other than the one on the very bottom, so I decided to echo $id ($id = $_POST['id'];) to see what was actually happening and for some reason on all the forms $id is getting set to the ID of the last form on the page.

 

However, when I look on the source of the page the ID's for all the forms that are generated is fine.

 

Example:

 

Form #1 - ID: 82

 

Form #2 - ID: 81

 

Form #3 - ID: 80

 

Then if I submit it from any of the forms, ID it changing to the ID of the bottom form.

 

Why is it doing this?

This is the form that's auto generated for every database row.

 

echo "<div id=\"".$div."\">

	<form action=\"delete.php\" method=\"post\">
	Password: <input type=\"password\" name=\"password\" />
	<input type=\"hidden\" name=\"id\" value=\"".$getid."\" />
	<input type=\"submit\" value=\"Delete\" />
</div>";

 

Now, when I echo the variable for each row, it's fine. It changes for each row. Also, when I view the source of my page, the field has changed for each form generated.

 

But when the form is submitted, it outputs $_POST['id']; as the same for every form, whatever the value is for the form on the very bottom of the page.

Your form is invalid because it does not have a closing </form> tag. What is probably happening is everything after the first opening <form tag on the page is considered part of that first form.

 

And your other thread on this, has the same problem of no </form> tags.

Your form is invalid because it does not have a closing </form> tag. What is probably happening is everything after the first opening <form tag on the page is considered part of that first form.

 

And your other thread on this, has the same problem of no </form> tags.

Oh, thanks a lot, that explains why it was working before but doesn't work now, must've made a mistake when I was editing something, can't believe I didn't notice that, thanks a lot!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.