Re: Form with 2 submit buttons

From: Date: Sun, 03 Sep 2000 07:05:08 +0000
Subject: Re: Form with 2 submit buttons
Groups: php.general 
Request: Send a blank email to php-general+get-14964@lists.php.net to get a copy of this message
Addressed to: <bhorton@pneumasoft.com> php-general@lists.php.net ** Reply to note from <bhorton@pneumasoft.com> Sat, 2 Sep 2000 23:34:41 -0600 > > Anyone know a good way to have a form submit with one of two different > submit buttons? > > I have a form and want all of the variables of the form passed to one > of two different functions depending on which action the user chooses. > > I'm using PHP 4 and have a session available if that helps but because > it's after the server's processed the information I can't think of how > that will really help. > > Any ideas? In the form: ------------------------------------------ <FORM ...> # All your fields <INPUT TYPE=Submit NAME=Action VALUE=One> <INPUT TYPE=Submit NAME=Action VALUE=Two> </FORM> ------------------------------------------ In the ACTION= program executed by the form ------------------------------------------ if( 'One' == $Action ) { # Do 'One' Thing } elseif( 'Two' == $Action ) { # Do 'Two' Thing } ------------------------------------------ Note that NAME=Action : Variable=$Action VALUE=One|Two : Value you look for = One|Two There is no limit to the number of actions available. You could also use SWITCH statement instead of IF/ELSEIF. Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#14964) next »