• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
prevent re-inserting data.

#1
[eluser]ede196620[/eluser]
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.

#2
[eluser]TheFuzzy0ne[/eluser]
As soon as validation passes, I like to redirect the user to another location. This prevents double submissions.

Code:
redirect('/some_controller/form_success');

#3
[eluser]ede196620[/eluser]
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.

#4
[eluser]TheFuzzy0ne[/eluser]
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.

#5
[eluser]Otemu[/eluser]
Hi,

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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.