php prevent form from being submitted repeatedly Example:
Copy code The code is as follows: >
session_start();
$_SESSION['fsess']=($_SESSION['fsess'])?$_SESSION['fsess']:time();
?>
Prevent repeated form submissionsJavascript and server-side dual prevention of repeated form submission demonstration
Current time:
if(@$_POST["faction"] =="submit"||@$_GET["faction"]=="submit"){
//Submission processing
//*****Server-side anti-repeated submission*** ****************
//If the form generation time from POST is the same as the form generation time saved in SESSION
//; it is submitted normally
/ /Not the same; for repeated submission
if($_SESSION["fsess"]==$_POST["fpsess"]){
$_SESSION["fsess"]=time();
echo " Submit content:
n";
echo $_POST["fpsess"]."
n";;
echo $_POST["formtext"];
echo "";
exit;
} else {
echo "Re-submit, exit! ! ! !
n";
echo "