> 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
> happening?

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
though.

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 :)

Cheers


Justin French
--------------------
http://Indent.com.au
Web Development & 
Graphic Design
--------------------


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to