Avoid duplicate entry in database onSubmit event.

berde,jitendra , March 01 2012
b
berde,jitendra

Hi All,

First of all i want to say Thanks to all whoever thought to build such a good form Component of Joomla. Now coming to point, I have created few forms in ChronoForms and all are working fine. However, at one point i am facing problem in it. There are few users who click Submit button multiple times after feeling data into form fields and because of it; same data is getting added multiple time. Now i don’t want duplicate entry get submitted multiple time and ruin my database with same entries.

Suppose if user click 5 times on Submit button after feeling data in form then user form data will only get submitted one time and all other four attempts will not get updated in database.

Any solution. Or Code which i can add onSubmit event.

Regards,
Jeet

GreyHead

Hi Jeet,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

There are anti-flooding settings in CFv3 on the Form General tab; and I have an Anti Flood [GH] action for CFv4 you can get here

Bob

b
berde,jitendra

Hi GreyHead,

Thank you for your reply. I am running V4 of Chrono forms. I have downloaded "Anti Flood [GH] action for CFv4". But can you let me know where should i place this file on my server. Sorry but i dont have idea about "Form General tab". Are you talking about tabs we have like as below:
Preview
Emails
Thanks Message
Files Uploads
Code
Anti Spam
Store Data
Form Settings


I have all this tabs not the one you mentioned. Can you please help me out in integration too.

Thank in advance.

GreyHead

Hi Jeet,

[list=a]

  • Install the action using the Install Action icon on the Forms Manager toolbar

  • Take a backup copy of your form just in case.

  • Open your form with the Wizard Edit link, then switch to the Advanced Wizard.

  • Click the actions tab at the left

  • Open the Utilities group of actions and drag an Anti Flood action into the On Submit event at the right.

  • Move the Anti Flood action up so that it is the first action in the On Submit event.

  • Open the action configuration with the 'spanner' icon next to the red x and check the Help tab.
  • [/list:o]

    Bob

    b
    berde,jitendra

    Hi GreyGead,

    As per your instruction. I installed mentioned action and added on top of onSubmit event. But still its not working. I have updated my form with Advance Mode option. Please find attached image for your information to check if i have made any mistake in it.

    Regards,
    Jeet

    Attachments
    anit_flood.jpg.jpg
    anit_flood.jpg.jpg
    (114.97 KiB)
    2285 Downloads/Views
    GreyHead

    Hi Jeet,

    You don't have any action in the On Fail event so it won't do anything. The least you need is to drag an Event Loop action in there to re-load the form. I think there is more information on the action Help Tab

    Bob

    b
    berde,jitendra

    Thank you for your help GreyHead.

    I have added Event loop action and now data is updating with single entry after multiple clicks on Submit button. However, i came across with one more problem on Email Field. After multiple submission in the email fields i receive javascript code as below:

    				<script type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy81163 = 'yourname' + '@'; addy81163 = addy81163 + 'domain' + '.' + 'com'; document.write('<a ' + path + '\'' + prefix + ':' + addy81163 + '\'>'); document.write(addy81163); document.write('<\/a>'); //-->\n </script><script type='text/javascript'> <!-- document.write('<span style=\'display: none;\'>'); //--> </script>This email address is being protected from spambots. You need JavaScript enabled to view it. <script type='text/javascript'> <!-- document.write('</'); document.write('span>'); //--> </script>
    				


    Any guess why is getting displayed? i hope you will good solution for this too. Email field is mandatory with email format check. Is it a cause of such an error?

    Regards,
    Jitendra

    GreyHead

    Hi Jeet,

    You have the Joomla! Email Cloaking Plug-in enabled and it is trying to cloak the sample e-mail in the ChronoForms validation message. Disable the plug-in temporarily to check this is the problem. If you need the plug-in change the plug-ins order so that Email Cloaking runs before ChronoForms.

    NB These are Joomla! plug-ins that you manage from Site Admin | Extensions | Plug-in Manager

    Bob

    b
    berde,jitendra

    Thanks GreyHead for your help. As per your recommendation i have set off that plugin and it work perfect. Now i do not get any script error in email field.

    One quick question to you. On Submit event i added Anti Flood event and in that set Event Group option. However when i try to edit setting section then i get empty event drop down. I do have multiple event set on my form.

    Right now, On multiple click form get stop and throw an error. But instead of show error it should get redirect to thank you page. I tried to place redirect event after event loop but that didn't work. Please check the attached image for your information.

    Hope you will solution on this too. Thanks in advance and once again thank you for your earlier help too.

    Regards,
    Jeet

    Attachments
    fomr.jpg.jpg
    fomr.jpg.jpg
    (85.42 KiB)
    2222 Downloads/Views
    GreyHead

    Hi Jeet,

    The default value of the Event Loop is the one you need so having it blank isn't a big problem.

    But, the bug has been fixed in the latest release so please upgrade your ChronoForms to CFv4 RC3.2

    The event loop will only 'fire' the On Fail event on the second or later clicks so the action you put in there will only be used then. You can choose which action to use. If you use an Evetn Loop then the form will be re-dsiplayed; if you use a Thank You Message action then a message will be shown; if you use a Redirect User action then the user will be redirected to another page.

    Bob

    b
    berde,jitendra

    Thanks for your prompt reply.

    Can i set custom code instead of Event loop? So it will have redirection code. I don't want to set Redirect User action as i want to submit my form data in different database too.

    Hope it will work. Please let me know your suggestion on it.

    Thanks in advance.

    GreyHead

    Hi Jeet,

    You can put any action you like in the Anti Flood action On Fail event BUT remember that it will only run when you want to block repeating submissions so it had nothing to do with your saving the data from the first submission.

    Bob

    b
    berde,jitendra

    Hi GreyHead, Thank you for all your assistance. i will get back to you if i face any problem. Right now upgrading form version.

    b
    berde,jitendra

    Hi GreyHead,

    As per your suggestion i have updated chrono form version with latest one. Now Events are getting displayed in drop list of Anti Flood fail option. However, it seems they are not getting listed all together as i do have almost for action on "On Submit" event button only Anti flood option get listed in drop down. I have attached image with this post for your better understanding. Top image part (1) have all action listed on my forms. Bottom part (2) have drop down of all event.

    I observed that Event loop is sub action on On Submit and still is getting listed in drop down but others are not.

    Could you please take a look into it. Still i am waiting to get things perfect as i want.

    Attachments
    antiflood.jpg
    antiflood.jpg
    (83.28 KiB)
    1907 Downloads/Views
    GreyHead

    Hi Jeet,

    That looks OK to me. The drop-down lists all three of the available events (not the actions).

    You want it set to the default > On Load to re-load the form.

    Bob

    b
    berde,jitendra

    Thanks GreyHead for your prompt reply. I got your point. Now, i have moved few of my action into On redirect Event and they are as below:
    1) Handle Array
    2) DB Save
    3) Email
    4) custom code (to redirect and submit data in different database)

    In the flood Fail i selected Target event as "On redirect Event" and "Quit next actions" as 'No'. With this setting none of the action is getting place. Can you let me know how do i set all this action in different event. Am i doing anything wrong?

    GreyHead

    Hi Jeet,

    You want it set to the default > On Load to re-load the form.

    Bob

    b
    berde,jitendra

    Hi GreyHead,

    Do you mean i have to set On Load event to work other event? It seems i miss communicated with you with my earlier post. I don't want to display form again. Once user click on button it has to run following action.. (Which i have save it in different event)
    1) DB Save
    2) Email
    3) After email redirection to another page.

    The only case is i don't want form data get submitted twice time if any user click multiple time while submit the form. Hope you i mentioned it clearly what i want.

    Sorry for keeping you busy with this. Thanks for all your assistance.

    GreyHead

    Hi Jeet,

    The only case is i don't want form data get submitted twice time if any user click multiple time while submit the form.

    And what do you want to happen in this case???

    Bob

    b
    berde,jitendra

    Hi GrayHead,

    I am really thank you for all your help on this. I have made some changes in events and everything is working fine now. Every action taking place only once and on double click it will redirect to thank you page.

    You are very supportive and kind of person. Thanks for all you petitions and support to making this workable.

    Powered by ChronoForums - ChronoEngine.com

    ChronoForms Book

    The ChronoForms Book, written for ChronoForms v3 contains 350 pages of invaluable ChronoForms How-tos hints and tips.

    Note: many of the ideas can be used in ChronoForms v4 but the admin interface is very different and code examples may need to be modified.

    SSL

    Members Login

     

    2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for
    goods and services provided by ChronoEngine.com