Welcome Guest, Not a member yet? Register   Sign In
prevent re-inserting data.

Hello everyone i new to codeigniter currently i am working on my first project yes i am still a noob Smile my question is what methods are there in preventing double submissions on a form ? tnx for your posts in advance.

As soon as validation passes, I like to redirect the user to another location. This prevents double submissions.


Tnx for posting . I did think of this but the user can click the back button and submit the form again do u have any other suggestions ? i found out about Post/Redirect/Get method and trying to look in to that.

Are you simply wanting to prevent the user from accessing that form again, or to stop them submitting it again with the back button?

I've redirected for years, and it works for me. I see no reason why it shouldn't work for you. The back button just takes the user back to the form, it does NOT resubmit it if you redirect after you've saved the data to the database.


I use the method TheFuzzy0ne said and I haven't had any issues.
The main thing is that you have validation checks, for instance if a user registers to your site and refreshes the page, then your validation should check if a user exists before it does any insert. Now instead of getting the same record inserted into the database the user will get an error.

Another method is to use sessions to store unique id for each form and then process if the id matches.

Theme © iAndrew 2016 - Forum software by © MyBB