Re: Forms and destroying values
| From: | Colin Guthrie | Date: | Tue, 16 Jan 2007 14:23:12 +0000 |
| Subject: | Re: Forms and destroying values | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247144@lists.php.net to get a copy of this message | ||
Beauford wrote:
> Thanks, a little confusing there. You would think though that once the info
> is transmitted by the browser it would be forgotten by the browser. Anyway,
> I do have a work around, and since PHP can't do anything about what the
> browser does, this will have to suffice.
But a refresh button is basically a "retry the last operation" so it's
not surprising the same information is sent again.
The correct solution here is to use the technique mentioned by Satyam.
Bascially:
<form action="handler.php" method="post">
blah
</form>
handler.php
<?php
if (!empty($_POST))
{
// Do stuff with $_POST, store it in a DB whatever.
header('Location: hander.php')
exit;
}
// Normal page output not referring in any way to $_POST
echo "Normal Page".
// If you have to present the data previously given in $_POST, then
// either store it in a DB or in a Session when handling the data above,
// then access the data from the DB or Session here.
// EOF
?>
This technique also means that the "back button" in the users browser is
not "broken" by posting forms... which is nice.
Col