Kane250 Posted October 2, 2008 Share Posted October 2, 2008 I have two seperate forms on one page that submit data to MySQL. However, if the user hits the return key when trying to submit the second form, it activates the submit button for the first form. Is there any way to tell the browser to not do this? Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/ Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 Yes <form action="form.php"> Something: <input type="text" name="Something"> <input type="submit" name="submit" value="Something"> </form> <form action="form.php"> Something: <input type="text" name="SomethingElse"> <input type="submit" name="submit" value="SomethingElse"> </form> and then... <?php $submit = $_POST["submit"]; if($submit == "Something"){ // do something for form 1 } elseif($submit == "SomethingElse"){ // do soemthing for form 2 } else { echo "ERROR. YOU DIVIDED BY ZERO."; } ?> Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/#findComment-655257 Share on other sites More sharing options...
Kane250 Posted October 2, 2008 Author Share Posted October 2, 2008 So the text that appears on the submit button has to be different? There's no way of doing it all behind the scenes? Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/#findComment-655268 Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 Correct Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/#findComment-655270 Share on other sites More sharing options...
Kane250 Posted October 2, 2008 Author Share Posted October 2, 2008 Gotcha! Thanks! Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/#findComment-655272 Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 No problem! Press the "Topic Solved" button. Link to comment https://forums.phpfreaks.com/topic/126699-solved-multiple-forms-on-page-submit-button-question/#findComment-655274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.