Re: Using POST to pass variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Todd Cary wrote:

> When I have more than one button on a page, I us what I call a reentrant
> approach.  That is the page calls itself.
> 
> If the page is emailer.pgp, the the FORM tag would be
> 
> <form method="get" action="emailer.php">
> 
> At the top is
> 
> <?php
>    $send    = $_GET[btnSend];  // Send button pressed
>    $cancel  = $_GET[btnCancel];// Cancel is pressed
>    $message = $_GET[message];
>    if ($send) {
>      header("location: send.php?message=" . $message);
>    }
>    if ($cancel) {
>      header("location: index.php");
>    }
> ?>
> 
> Is there a better way to do this so I can use a POST form?
> 
> Thank you...
> 
> Todd
What about:

<form method="post" action="emailer.php">

and

if (isset($_POST['send']) ) {
  # do some sanitising on $_POST['message'] here
  header("location: http://f.q.d.n/path/to/send.php?message="; .
$_POST['message']);
}
exit();

if (isset($_POST['cancel']) ) {
   header("location: http://f.q.d.n/path/to/index.php";);
}

Add other sanity checks as required.


Cheers
-- 
David Robley

Do not put statements in the negative form.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux