Page 1 of 1

refresh page -help please

Posted: Tue Mar 13, 2007 12:04 am
by aniltc
hi all

I have a contact page and i am redirecting the page to same page after the mail sent sucessfully.But when i am refreshing the page ,all the data is again inserted into the database and agian sending a mail to same person.How
can i avoid this?

please help me


Thanks

Posted: Tue Mar 13, 2007 12:14 am
by Kieran Huggins
some people use a meta refresh tag on the "thank you" page -- this will move users on to a new page that's refresh-friendly.

Also, you should double check that the entry doesn't already exist before writing to the database.

Posted: Tue Mar 13, 2007 12:27 am
by aniltc
thanks


Is there any otherway without doing database check? I mean using session

Posted: Tue Mar 13, 2007 1:42 am
by aaronhall
Using

Code: Select all

header('Location: http://www.mysite.com');
would solve your problem. You could also set a session variable to a random string after the data is inserted, place a hidden input tag in the form with that same string, and check the random string in the session against the one in $_POST or $_GET.