David Dawes asked ... How to recoil the starter spring - Champion R484TR?    |    peter high asked ... How can I set time on my Neff oven?    |    Michael asked ... Mountfield empress drive belt?    |    John Barton asked ... How do i clear the TAM?    |    John asked ... How can I mend my binatone veva 1210 handset?    |    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