> When I reload the page the data gets stored once more. I'm sure this is a
> well known problem. Are there any smart tricks to prevent this from
Yes, and they get discussed on this list almost daily... a quick search
would have helped.
1. the "script" that does all the validating and inserting SHOULD NOT send
any output to the browser... after insert, put in a header("Location:
script.php?action=thanks") style redirect.
This means that if the user hits refresh, they will only be refreshing the
"thanks" page, NOT the insert page, because it never gets to the browser.
Yes, this can all be done in one script, it may need some re-organisation
2. when generating the HTML form, include a hidden field with a unique
string in it. Insert this string with the rest of the form data, and make
sure that this string is only inserted once... so, if they hit "refresh",
you'll know that the form has already been submitted, and the data already
inserted, so don't insert it again :)
Web Development &
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php