Re: Multiple submit's on one form
| From: | Dennis Moore | Date: | Wed, 07 Aug 2002 17:20:14 +0000 |
| Subject: | Re: Multiple submit's on one form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111544@lists.php.net to get a copy of this message | ||
Here...Here...
You have a couple of options:
1. Place a form tag around each of the form buttons You will need to place
is separate HTML table cells to layout properly.
2.. Or build a page that redirects based upon the value of the submit
button.
<?php
if($name=="B1") {
header("Location: http://yoursite.com/yourpage.php");
} else if ($name=="B2") {
// and so on...
}
?>
}
You have a couple of options:
1. Place a form tag around each of the form buttons You will need to place
is separate HTML table cells to layout properly.
2.. Or build a page that redirects based upon the value of the submit
button.
<?php
if($name=="B1") {
header("Location: http://yoursite.com/yourpage.php");
} else if ($name=="B2") {
// and so on...
}
?>
You could also use the same name for the submit buttons and use a
switch-case statements instead of if statements.
/dkm
}
?>
----- Original Message -----
From: "Adam Plocher" <aplocher@erepublic.com>
To: "'Saci'" <nospam@bol.com.br>
Cc: <php-general@lists.php.net>
Sent: Wednesday, August 07, 2002 1:05 PM
Subject: RE: [PHP] Multiple submit's on one form
> Probably the best way would be to have it submitted to only one PHP page
> then have that page forward you.
>
> Example:
>
> If ($B1 == "Save")
> Header("Location: http://www.url.com");
> Elseif ($B2 == "Back")
> Header("Location: http://www.url2.com");
>
> .. Etc ..
>
> To have the variables passed from the form to those pages you could use
GET
> vars or something.
>
> Hope this helps..
>
> -Adam
>
> -----Original Message-----
> From: Saci [mailto:nospam@bol.com.br]
> Sent: Wednesday, August 07, 2002 9:51 AM
> To: php-general@lists.php.net
> Subject: [PHP] Multiple submit's on one form
>
>
> I have a form working well and I need 4 different submit buttons,
something
> like this
>
>
>
> <form method="POST" action=myphpcode.php>
>
> <table border="0" cellpadding="1" bgcolor="#E0DFE3">
>
> ...
>
> ..
>
> ..
>
> ..
>
> ..
>
>
>
> <tr>
>
> <td bgcolor="#E0DFE3">
>
> <input type="submit" value="Save" name="B1"></td>
>
> <td bgcolor="#E0DFE3">
>
> <input type="submit" value="Back" name="B2"></td>
>
> <td bgcolor="#E0DFE3">
>
> <input type="submit" value="Refresh"
> name="B3"></td>
>
> <td bgcolor="#E0DFE3">
>
> <input type="submit" value="Search"
> name="B4"></td>
>
> </tr>
>
> </table>
>
> </form>
>
> </body>
>
> </html>
>
>
>
>
>
> I would like to call 4 different php pages according to the one of the 4
> buttons pressed.
>
>
>
> Button B1 will post to myphpcode1.php
>
> Button B2 will post to myphpcode2.php
>
> Button B3 will post to myphpcode3.php
>
> Button B4 will post to myphpcode4.php
>
>
>
> How can I define that since the form has only one post method?
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>