RE: [PHP] Two Actions in a Form?
| From: | Jay Blanchard | Date: | Wed, 26 Nov 2003 19:00:54 +0000 |
| Subject: | RE: [PHP] Two Actions in a Form? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-171123@lists.php.net to get a copy of this message | ||
[snip]
have the PHP script that receives the post to distinguish between which
button the user clicked.
Name your submit button different names, then use print_r($_POST) or
print_r($_GET) - depending on whether you use POST or GET, and I
thinkyou'll see what you need to be checking.
[/snip]
Another method is to name the buttons the same, but each has a different
value....(using POST as an example)
<form action="process_form.php" method="POST">
<input type="submit" name="action" value"Do Action One">
<input type="submit" name="action" value"Do Action Two">
</form>
Then use a switch/case statement to decide what to do....
http://us2.php.net/switch
<?php
switch($_POST['action']){
case "Do Action One":
/* do stuff */
break;
case "Do Action Two":
/*do other stuff */
break;
}
?>