Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One method for ensuring that a POST is not resubmitted is have a unique identifier associated with that post session, for example, if it's a shopping cart, when they begin checking out, generate a unique ID for that process. Once the checkout has completed (e.g. POST has been sent), remove that ID from the ID's that can be used.</p> <p>You could also do this by generating a unique key with the form, and if the form is submitted, remove that key from where it is stored.</p> <pre class="lang-php prettyprint-override"><code>&lt;input type="hidden" name="key" value="&lt;?php echo generateUniqueKey(); ?&gt;" /&gt; </code></pre> <p>where the generateUniqueKey() function will query a table and insert a unique ID, then return the ID. On the page where you are processing the form, do something like this:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php $key = $_POST['key']; if (isKeyStillValid ($key)) { markKeyAsInvalid ($key); // Process form ... } else { die ("You have already submitted this form".); } ?&gt; </code></pre> <p>Where the isKeyStillValid() function will check the database to ensure the key used with the form is still a useable key, and the markKeyAsInvalid() function will remove the key from the database.</p> <p><strong>Update:</strong> Here's an example that I just made which involves exactly what I described earlier. This is a very simple example, and simply uses an auto-incrementing ID in a SQL table as the key, but it should be sufficient as an example. Realistically, you would want something more thought out than this. <a href="http://alexloney.com/post/" rel="nofollow">http://alexloney.com/post/</a></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.
 

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