ag3nt42 Posted June 2, 2008 Share Posted June 2, 2008 I have a form for an install file i'm setting up.. I would like to be able to create two submit buttons for the one form and have one submit button go to one page and the other to another. Anyone have ne ideas on this plz share. thankx, ag3nt Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/ Share on other sites More sharing options...
rhodesa Posted June 2, 2008 Share Posted June 2, 2008 it requires that javascript is enabled...but it works: <form action="test1.php"> <input type="submit" /> <input type="submit" onclick="this.form.action='test2.php';" /> </form> Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555645 Share on other sites More sharing options...
GingerRobot Posted June 2, 2008 Share Posted June 2, 2008 Why bother? Give the submit buttons different names and handle them on the same page. Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555647 Share on other sites More sharing options...
ag3nt42 Posted June 2, 2008 Author Share Posted June 2, 2008 i can't handle them on the same page.. I need them to go to seperate pages.. thanks rhodesa i'll give that a shot Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555650 Share on other sites More sharing options...
rhodesa Posted June 2, 2008 Share Posted June 2, 2008 If they have to be separate pages, then do it that way. But GingerRobot's option is the better way to handle it. Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555653 Share on other sites More sharing options...
GingerRobot Posted June 2, 2008 Share Posted June 2, 2008 i can't handle them on the same page.. I need them to go to seperate pages.. thanks rhodesa i'll give that a shot Unless your posting to another website, then why not? You can handle the form's on one page and redirect someone to the appropriate page after. Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555656 Share on other sites More sharing options...
mushroom Posted June 2, 2008 Share Posted June 2, 2008 if ($submit_button=="other_option") { include("other_php_page"); # code for that button } elseif ($submit_button=="normal_option") { # code for that button } else { # code for no button } Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555662 Share on other sites More sharing options...
ag3nt42 Posted June 2, 2008 Author Share Posted June 2, 2008 its ok the first options worked the best for me guys.. basically one button runs a database connection test and the other runs the install file. But I needed the test button to display the information directly on that page rather then sending them to another one. I spose you could do that on the same page and the redirect them after wards but this seems so much simpler on everyone. thankx for all the options though guys.. i really appreciate your responses. Link to comment https://forums.phpfreaks.com/topic/108385-solved-form-to-kill-two-birds-with-one-stone/#findComment-555695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.