HI All

I am relatively new to PHP and am in the processing of developing a site making use of PHP and MySQL. The problem I am experiencing is that when I refresh Internet Explorer, the data that was processed by a form is resubmitted to the database - can anyone tell me what the correct process is to avoid having this happen. The only thing that comes to mind is to, after the processing is complete, redirect to another screen - ultimately I would like to avoid doing that.

Any ideas?

Thanks in advance


6 Years
Discussion Span
Last Post by designershiv

You might want to implement a session token or javascript redirect. A session token gets implemented before page execution and on page execution it gets destroyed. And the javascript way has its obvious implementations. Also, your database could assist in this if you are inserting the unique value which to compare against.


Always try to practice with header.

		/* ----------
		   your code 
		 ------------ */

Because if there is no header and you press refresh then form will be resubmitted.


You are absolutely right EverWebby. I have encountered the same problem before and I made use of the following options:

1. I was storing a unique ID in the mysql database and what I did is that if the page is refreshed, I would check on the database if this ID has been recorded before. If so I then redirected the user to another page. But Mysql queries are expensive to make, so I will encourage you to use redirection where possible:

2. To implement redirection in PHP you user:


In this case I redirect the user to my default index.php page.

Hope it helps :-)

Edited by sithembisophp: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.