ajoo Posted May 31, 2014 Share Posted May 31, 2014 Hi I am trying to split a form as shown in this simple code. I tried what I thought should work but obviously it is not working. This submits the first part of the form but does not go to the second part of the form. So First name, Last names and Age are submitted but email and cell are not and it throws a undefined index warning for those. Can someone please take a look at this and suggest if what I am trying to do can be accomplished using PHP. Thanks <?php if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') { echo"<br> First Name = ".$_POST['fname']."<br>" ; echo"Last Name = ".$_POST['lname']."<br>" ; echo"Age = ".$_POST['age']."<br>" ; echo"Email = ".$_POST['email']."<br>" ; echo"Cell = ".$_POST['cell']."<br>" ; } ?> <html> <head> <title> WOW </title></head> <body> <table> <form id="form1" action = "splitform.php" method="post"> <th> TEST </th> <tr><td>First Name : </td> <td><Input type='text' name = 'fname'></td></tr> <tr><td>Last Name : </td> <td><Input type='text' name = 'lname'></td></tr> <tr><td>AGE : </td> <td><Input type='text' name = 'age'></td></tr> </form> <form id ="form1" action = "splitform.php" method="post"> <tr><td>Email : </td> <td><Input type='text' name = 'email'></td></tr> <tr><td>Cell: </td> <td><Input type='text' name = 'cell'></td></tr> </form> <tr><td><Input type="submit" name = "submit" value = "Submit" form = "form1"></tr></td> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Solution PravinS Posted May 31, 2014 Solution Share Posted May 31, 2014 why do you want to split the form, it can be done in single form Quote Link to comment Share on other sites More sharing options...
fastsol Posted May 31, 2014 Share Posted May 31, 2014 Yeah why would you want to split that form up? It's a fairly pointless idea in this case. The only real times you do that is if there are many steps to filling a form out and you want to save the progess for the client. Plus you have invalid html by having the id the same between the 2 forms. Id's must be unique to the page. Quote Link to comment Share on other sites More sharing options...
Ansego Posted May 31, 2014 Share Posted May 31, 2014 (edited) Normally when I see 'undefined index' I straight away look for isset(). Also remove; </form> <form id ="form1" action = "splitform.php" method="post"> No sense having two forms going to the same place and same collective data. Maybe let us know why your trying to split the form and we might have a better solution for you. As far as I can tell only reason to split a form is to have form steps, ie name / email : submit -> age / sport: submit -> Confirmation. (But seems pointless unless huge form) Edited May 31, 2014 by Ansego Quote Link to comment Share on other sites More sharing options...
ajoo Posted June 1, 2014 Author Share Posted June 1, 2014 Yes Thanks , I guess that was not required as correctly pointed by all of you. Thanks Quote Link to comment Share on other sites More sharing options...
Ansego Posted June 1, 2014 Share Posted June 1, 2014 Please mark answered on one of the top two posts please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.