RE: [PHP] submit form to php script problem
| From: | John Holmes | Date: | Wed, 19 Jun 2002 14:19:17 +0000 |
| Subject: | RE: [PHP] submit form to php script problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102938@lists.php.net to get a copy of this message | ||
You'll have to use header()if you want to do it server side.
<input type='submit' name='submit' value='page1'>
<input type='submit' name='submit' value='page2'>
<input type='submit' name='submit' value='page3'>
$_POST['submit'] will exist and be one of the pages.
Switch($_POST['submit'])
Case "page1":
Header("Location: http://www.example.com/page1.php");
Etc...
The trick is passing the form variables. If you use GET for your form,
you can recreate the query string and put it in the address in the
header() call (then change _POST to _GET, of course). Or you can try
entering the entire $_POST array into the session and handle it on
page1, page2, etc...
<?
Session_start();
If(isset($_POST['submit'])
{
$_SESSION['POST'] = $_POST;
switch($_POST['submit'])
{
case "Page1":
header("location: http://www.example.com/page1.php");
...
Hope that helps or gives you an idea...
---John Holmes...
> -----Original Message-----
> From: Mark Colvin [mailto:mark.colvin@ccmltd.co.uk]
> Sent: Wednesday, June 19, 2002 8:33 AM
> To: Php (E-mail)
> Subject: [PHP] submit form to php script problem
>
> I have a form with three submit buttons on it. I would like the form
> 'action' to be dependant on which submit button the user pressed i.e.
> redirect to one of three php script files. Is there any way of doing
this
> without using client side scripting? I tried the code below where
$name
> corresponds to one of the submit button names, but I realise this
won't
> work
> as the form would have to be sent to the server before $name could be
> determined. Any other thoughts would be appreciated.
>
> <form action="<?
> switch ($name)
> {
> case search:
> ?>searchoutput.php<?
> break;
> case add:
> ?>addoutput.php<?
> break;
> case admin:
> ?>adminoutput.php<?
> break;
> }
> ?>" method="post">
>
> Thanks in advance
>
> Mark
>
>
> ****************************************************
> This e-mail is intended for the recipient only and
> may contain confidential information. If you are
> not the intended recipient then you should reply
> to the sender and take no further ation based
> upon the content of the message.
> Internet e-mails are not necessarily secure and
> CCM Limited does not accept any responsibility
> for changes made to this message.
> Although checks have been made to ensure this
> message and any attchments are free from viruses
> the recipient should ensure that this is the case.
> ****************************************************
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php