0

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

Shiv

4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by designershiv
0

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.

0

Always try to practice with header.

<?
	if(isset($_REQUEST['submit']))
	{
		/* ----------
		   your code 
		 ------------ */
		 header("Location:page.php");
		 exit;
	}
?>

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

0

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:

header("location:http://www.mywebsite.com/index.php");
exit;

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.