Prevent Multiple Submissions on the Client Side in PHP

Description

The following code shows how to prevent Multiple Submissions on the Client Side.

Example


//www  .  java  2s. c o m
<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'];

?>




















Home »
  PHP Tutorial »
    Form »




PHP Form
Form Demo