Omzy Posted February 2, 2010 Share Posted February 2, 2010 Basically on my page I have 3 identical forms, for example: <form method="post" action=""> <input type="text" name="name" value="<?php echo isset($_POST['name']) ? $_POST['name'] : null ?>" /> <input type="text" name="email" value="<?php echo isset($_POST['email']) ? $_POST['email'] : null ?>" /> <input type="hidden" name="form1" /> </form> The hidden variable at the end helps me identify which form was submitted. I've implemented validation and all is fine, apart from one thing. Whenever a form is returned back with validation errors, the matching fields on the other forms also get populated. Obviously this is because they all share the same 'name' attribute, but I have a requirement to keep the same names across all forms. I could of course extend the isset() check to also check for the hidden field, but this creates too much replication. Anybody have an elegant solution to this slight problem? Link to comment https://forums.phpfreaks.com/topic/190669-multiple-forms-on-the-page-and-validation/ Share on other sites More sharing options...
Omzy Posted February 2, 2010 Author Share Posted February 2, 2010 Anyone able to help? Link to comment https://forums.phpfreaks.com/topic/190669-multiple-forms-on-the-page-and-validation/#findComment-1005584 Share on other sites More sharing options...
Omzy Posted February 2, 2010 Author Share Posted February 2, 2010 Anybody in the forum able to offer any suggestions? Link to comment https://forums.phpfreaks.com/topic/190669-multiple-forms-on-the-page-and-validation/#findComment-1005673 Share on other sites More sharing options...
akitchin Posted February 2, 2010 Share Posted February 2, 2010 i'm afraid you're either going to have to name the fields uniquely for the given form, or you'll have to check for the hidden variable as well when repopulating. there's no way for the server to know intuitively which fields to populate. Link to comment https://forums.phpfreaks.com/topic/190669-multiple-forms-on-the-page-and-validation/#findComment-1005712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.