Bluehost.com Web Hosting $6.95

RE: [PHP] Two Actions in a Form?

This is a discussion on RE: [PHP] Two Actions in a Form? within the PHP General forums, part of the PHP Programming Forums category; [snip] have the PHP script that receives the post to distinguish between which button the user clicked. Name your submit ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-26-2003
Jay Blanchard
 
Posts: n/a
Default RE: [PHP] Two Actions in a Form?

[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;
}

?>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:16 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0