Re: Form with 2 submit buttons

From: Date: Thu, 07 Sep 2000 15:30:12 +0000
Subject: Re: Form with 2 submit buttons
Groups: php.general 
Request: Send a blank email to php-general+get-15731@lists.php.net to get a copy of this message
Samantha Savvakis wrote: >HI, >I want to know what is the best way to go about this situation. >I have a set of pages that make up a wizard type implementaion, so I have a >"Previous" and a "Next" button on each page. >Both of these buttons are on the Same <FORM>. Each button has a different >action -eg. Previous button goes to page1.php and Next button goes to >page3.php. >When I submit, it submits to itself. Here is code example: [....] Hi, Sam: first of all, sorry for my bad english :-( I had the same problem as you, and I find the best solution is *not* to have not 1 form with 2 buttons, but 2 different forms (with the same action="....."), each with one button. If you define the same variable with different values inside each form, you can easly know wich button was clicked. (Also, if you press ENTER, nothing will happend: you have to press one of the buttons to submit the form). Something like this: <BODY> <FORM METHOD=POST ACTION=samephpfile.php3> <INPUT type=text name....> <INPUT type=text name....> <INPUT type=hidden name=wich_button value=prev> <INPUT type=submit name=btnPrev value="Previous"> </FORM> <FORM METHOD=POST ACTION=samephpfile.php3> <INPUT type=text name....> <INPUT type=text name....> <INPUT type=hidden name=wich_button value=next> <INPUT type=submit name=btnNext value="Next"> </FORM> </BODY> I hope that helps you -- murgas!!

« previous php.general (#15731) next »