Support Forums

Full Version: How can I prevent this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On all of my post and gets, you can just f5 and submit the data over and over, is there an easy way to avoid this?
Use a cookie so it can detect if they've F5'd in the last 10 seconds, and if they have then use an if statement to stop the post/get.
(08-25-2010, 04:12 AM)Starky Wrote: [ -> ]Use a cookie so it can detect if they've F5'd in the last 10 seconds, and if they have then use an if statement to stop the post/get.You need us to wipe your ass for you too?

There was really no need to be rude about it.

@OP: Alternatively, you can store what they POSTed (you should serialize() it) and the time in a mysql table, and if the same data was stored less than x seconds ago, don't process.
(08-25-2010, 02:52 AM)`P R O D I G Y™ Wrote: [ -> ]On all of my post and gets, you can just f5 and submit the data over and over, is there an easy way to avoid this?

You should be redirecting your users away from the form after it has been validated and executed. Doing so will mean that if your user decides to spam the refresh button they'll be doing so on a safe page. How it might look in pseudocode:

Code:
if form submitted then
  validate form

  if form validates successfully then
    redirect user
This is a problem for me too, if they click back, it repeats the GETs.
(10-06-2010, 09:00 PM)Disease Wrote: [ -> ]You should be redirecting your users away from the form after it has been validated and executed. Doing so will mean that if your user decides to spam the refresh button they'll be doing so on a safe page. How it might look in pseudocode:

Code:
if form submitted then
  validate form

  if form validates successfully then
    redirect user

Hey, that would work pretty nicely. But that would mean that each submissApproachion would require its own success page, and if done half-assed (like most of my scripts) it can get messy real quick
I don't know!
I'de love a way too avoid that as well. xD
(11-30-2010, 02:47 PM)iCrack Wrote: [ -> ]I don't know!
I'de love a way too avoid that as well. xD

Well considering Disease just explained how to do it, I don't see why you don't know.