Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Give a <em>session</em> to the user</li> <li>Define a variable in the session named <em>last-submit</em> and give it the current time as the value.</li> <li>When the form results comes in: <ol> <li>Check what was the <em>last-submit</em> value.</li> <li>If it was more than <em>x</em> seconds ago, then save the <em>time</em> as the <em>last-submit</em> and respond respectively.</li> <li>If it was less than <em>x</em> seconds, reject the form and respond respectively.</li> </ol></li> </ol> <p>If you want to prevent the robots or scripts, then do the following as well:</p> <ol> <li>Add an input field to the form, name it _robo_trap_ and make it invisible to the human-eye by set the style to <code>display: none</code>.</li> <li>When the forms come in check if the <code>robo_trap</code> has any value or if its default value has already changed. If it was, then discard the form because humans can't see and don't need to fill that up.</li> </ol> <p>For example:</p> <pre><code>&lt;?php /* User Session */ session_start(); /* Current Time */ $now = new DateTime(); /* First Time ... */ if ( empty($_SESSION['last-submit']) ) { $_SESSION['last-submit'] = $now; } /* On Form Submit ... */ if ( !empty($_POST) ) { /* How fast?! */ $gap = now-&gt;diff( $_SESSION['last-submit'] ); $gap = $gap-&gt;format('%s'); if ( $gap &gt; 1 ) { // good ... $_SESSION['last-submit'] = $now; } else { // bad ... } } </code></pre> <p>P.S. Just a sample code to give you some ideas, I didn't test it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload