RE: [PHP] Form with 2 submit buttons
| From: | Craig Vincent | Date: | Sun, 03 Sep 2000 14:46:23 +0000 |
| Subject: | RE: [PHP] Form with 2 submit buttons | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14984@lists.php.net to get a copy of this message | ||
<snip>
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.
</snip>
As long as you don't mind having the form submit to the same page you can
have as many different submit buttons with each one performing a different
task
<FORM METHOD="POST" ACTION="foobar.php3">
<INPUT TYPE="submit" name="action" value="do_this">
<INPUT TYPE="submit" name="action" value="do_that">
<INPUT TYPE="submit" name="action" value="do_something_else">
</FORM>
-> foobar.php3
<?
if ($action == 'do_this') {}
elseif ($action == 'do_that') {}
elseif ($action == 'do_something_else') {}
?>
Sincerely,
Craig Vincent