title: Prevent multiple form submission on multiple clicks in PHP or JavaScript
body: <p>I want to prevent multiple form submission on multiple clicks. </p>
  
  <p>I actually want to insert data into the DB. The process takes a little time, like 2-3 second.</p>
  
  <p>The problem is, that within the 2-3 second the visitor can click about 6-7 times to that button, and it will run the script over and over again.</p>
  
  <p>How can i prevent it?</p>
  
  <p>I tried this code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
    &lt;head&gt;
      &lt;title&gt;My Form&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form action="process.php" method="post"&gt;
        &lt;input type="hidden" name="form_token" value="&lt;?php echo $form_token; ?&gt;" /&gt;
          &lt;div&gt;
        &lt;label for="name"&gt;Name&lt;/label&gt;
        &lt;input type="text" name="name" /&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;input type="submit" value="Add Name" onclick="this.disabled=true;return true;" /&gt;
          &lt;/div&gt;
        &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>