Home > php教程 > PHP源码 > 【PHP】Web服务器端防止表单的重复提交

【PHP】Web服务器端防止表单的重复提交

PHP中文网
Release: 2016-05-25 17:16:01
Original
1022 people have browsed it

<html>
<body>
<form action="index.php" method="post">
<input type="hidden" name="submitted" value="yes" /> Your Name: <input
  type="text" name="yourname" maxlength="150" /><br />
<input type="submit" value="Submit" style="margin-top: 10px;" /></form>
</body>
</html>
<?php
session_start ();
if (! isset ( $_SESSION [&#39;processing&#39;] )) {
  $_SESSION [&#39;processing&#39;] = false;
}
if ($_SESSION [&#39;processing&#39;] == false) {
  $_SESSION [&#39;processing&#39;] = true;
    //validation 
  if ($file = fopen ( "test.txt", "w+" )) {
    fwrite ( $file, "Processing" );
  } else {
    echo "Error opening file.";
  }
  echo $_POST [&#39;yourname&#39;];
  unset ( $_SESSION [&#39;processing&#39;] );
}
?>
Copy after login


source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template