Michdd Posted October 25, 2008 Share Posted October 25, 2008 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? Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/ Share on other sites More sharing options...
DarkWater Posted October 25, 2008 Share Posted October 25, 2008 We'd need to see relevant code. My guess is that you have the same name for every attribute. Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674505 Share on other sites More sharing options...
Michdd Posted October 25, 2008 Author Share Posted October 25, 2008 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. Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674506 Share on other sites More sharing options...
DarkWater Posted October 25, 2008 Share Posted October 25, 2008 Like I said, they all have the same name attribute. Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674508 Share on other sites More sharing options...
Michdd Posted October 25, 2008 Author Share Posted October 25, 2008 Like I said, they all have the same name attribute. If it's auto generated how can I get it to change the name for each one, and at the same time make the processing file work? Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674509 Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2008 Share Posted October 25, 2008 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. Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674514 Share on other sites More sharing options...
DarkWater Posted October 25, 2008 Share Posted October 25, 2008 Nice, I didn't even notice that. I misunderstood what he was using this code for; now I get it. Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674517 Share on other sites More sharing options...
Michdd Posted October 25, 2008 Author Share Posted October 25, 2008 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! Link to comment https://forums.phpfreaks.com/topic/130091-solved-2-forms-on-1-page-id-set-to-the-bottem-form-for-all/#findComment-674521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.