龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

【PHP】浏览器端阻止表单的重复提交

时间:2014-07-22 14:52来源: 作者: 点击:
分享到:
<无详细内容>
<html>
<script language="javascript" type="text/javascript"> 
function checkandsubmit() { 
  document.test.submitbut.disabled = true; 
  document.test.submit(); 
} 
</script>
<body>
<form action="index.php" method="post" name="test" onsubmit="return checkandsubmit ()">
<input type="hidden" name="submitted" value="yes" /> Your Name: <input
  type="text" name="yourname" maxlength="150" />
<input type="submit" value="Submit" id="submitbut" name"submitbut" /></form>
</body>
</html>
<?php
if ($file = fopen ( "test.txt", "w+" )) {
  fwrite ( $file, "Processing" );
} else {
  echo "Error opening file.";
}
echo $_POST ['yourname'];

?>
精彩图集

赞助商链接