refresh page -help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aniltc
Forum Newbie
Posts: 17
Joined: Thu Nov 16, 2006 6:42 am

refresh page -help please

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
aniltc
Forum Newbie
Posts: 17
Joined: Thu Nov 16, 2006 6:42 am

Post by aniltc »

thanks


Is there any otherway without doing database check? I mean using session
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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.
Post Reply