ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Problem: Data Saved - @ Form Reload

December 28, 2012 9:41am

Subscribe [1]
  • #1 / Dec 28, 2012 9:41am

    Shiju S S

    39 posts

    1. People click back button after saving a form and click submit again. Saving the form again. Usually when we have a auto generate Primary Key.
    2. Another situation is when they are clicking the refresh button data is saved again. This often occurs when we are editing or using Update commands.

    How can we stop saving data into data base when the refresh button is clicked.

  • #2 / Dec 28, 2012 10:04pm

    PhilTem

    872 posts

    1) Do a redirect after the data was successfully added (doesn’t prevent anyone from hitting the back button on the browser and submitting the form again)
    2) Check for a session flag before storing data in your database which will only be set on the first time that a form is submitted. From the first successful submit/storing you will deny storing the same data (hash it) if the session flag exists.

    That’s my two cents/solutions 😉

  • #3 / Jan 02, 2013 3:38am

    Shiju S S

    39 posts

    I got a script for getting it.

    <$cript type="text/javascript">
    $('form').submit(function() {
     $('.btn').attr('disabled', true).addClass('disabled');
    });
    </$cript>

    I cannot figure out what it does. Can someone explain.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases