GG asked ... Fix food processor motor?    |    T asked ... How do I turn the delay off on Electrolux DX302 dishwasher?    |    Helen asked ... How can I mend my Kenwood Gourmet FP505?    |    Roy Turner asked ... Kohlangaz Gosford HE fire?    |    Peter asked ... How can I mend a Powerwasher PRO PRO1800PWE?    |    Click here to ask your question

How can I stop a php form from being processed twice?

I am writing a web site and using PHP and MySQL database. I have developed a form. When this is submitted the browser is pointed to another php page which processes the input and thanks the visitor. I have found a problem. If the visitor refreshes the browser the data will be processed again. How can I ensure that the processing page cannot be run again when the user refreshes their browser?
Ray Wilks, March 2004
David if the user hits their Back Button the form will submit again. How would you stop this happening?

Jon, February 2005
If you have ever used a PHP-based discussion board then you would see how they deal with it, they create an intermediate page which does the saving and then redirect the user from their to the next page.

The intermediate page will usually say something like "Thanks for logging on, you are now being redirected back to the forum".

Of course, if they refreshed on this page then it would do the same double-post, but it is unlikely they will refresh during the second or two that redirection is taking place :)

David Carrington, May 2004