Using hash to check if page with $_POST values was refreshed
Posted
by Dieseltime
on Stack Overflow
See other posts from Stack Overflow
or by Dieseltime
Published on 2010-04-16T01:55:08Z
Indexed on
2010/04/16
2:03 UTC
Read the original article
Hit count: 258
When posting a form to the same PHP page, what is the correct method to find if the page was accidentally refreshed instead of submitted again?
Here's what I'm using right now:
$tmp = implode('',$_POST);
$myHash = md5($tmp);
if(isset($_SESSION["myHash"]) && $_SESSION["myHash"] == $myHash)
{
header("Location: index.php"); // page refreshed, send user somewhere else
die();
}
else
{
$_SESSION["myHash"] = $myHash;
}
// continue processing...
Is there anything wrong with this solution?
© Stack Overflow or respective owner