Home >Backend Development >PHP Tutorial >How to prevent PHP form from refreshing and submitting

How to prevent PHP form from refreshing and submitting

WBOY
WBOYOriginal
2016-07-29 09:12:081600browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn