jwhite68 Posted July 23, 2007 Share Posted July 23, 2007 I have a fairly simple PHP page, which takes form input for a message, and on pressing the send button, it sends an email out. The problem I have is that when a user presses refresh, it sends the email out again. I use a form action to send a hardcoded value of sent=1, which reruns the script in order to send the email out. So when pressing refresh, it still has this value of 1 set, and hence the issue. Does anyone have any advice on how best to deal with refresh, so its not processing the form again? Link to comment https://forums.phpfreaks.com/topic/61341-best-way-to-prevent-refresh-rerunning-php-code-in-script/ Share on other sites More sharing options...
btherl Posted July 23, 2007 Share Posted July 23, 2007 The simplest method I can think of is to set a session variable. If you're not familiar with sessions, it's time to learn They are very useful things. If you set the session variable when the form is first submitted, then you can test it the second time and recognize that something is awry. Link to comment https://forums.phpfreaks.com/topic/61341-best-way-to-prevent-refresh-rerunning-php-code-in-script/#findComment-305227 Share on other sites More sharing options...
jwhite68 Posted July 23, 2007 Author Share Posted July 23, 2007 Thanks. Thats done the trick. Link to comment https://forums.phpfreaks.com/topic/61341-best-way-to-prevent-refresh-rerunning-php-code-in-script/#findComment-305235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.