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? Quote Link to comment 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."; } ?> Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 Correct Quote Link to comment Share on other sites More sharing options...
Kane250 Posted October 2, 2008 Author Share Posted October 2, 2008 Gotcha! Thanks! Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 2, 2008 Share Posted October 2, 2008 No problem! Press the "Topic Solved" button. 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.