Home >Backend Development >PHP Tutorial >How to prevent PHP form from refreshing and submitting
Excerpted from http://bbs.chinaunix.net/thread-667547-1-1.html
-------------------------- ------------------------------------------
When outputting the form page: (An example, not perfect)
$intFlag = md5(time());
$strFlag = 'flag_$intFlag';
$_SESSION["$strFlag"] = 1;
Then when accepting data:
$action_flag = trim($_POST["action_flag"]);
if ($action_flag!="" && $_SESSION[" $action_flag"]==1)
{
$_SESSION["$action_flag"] = 2;
//Processing data
}
else
{
die("Duplicate submission or other errors");
}
The above introduces the method of preventing refresh submission of PHP forms, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.