wardo Posted April 21, 2006 Share Posted April 21, 2006 Hi,I have a form that users can mail me from on my website. At first, all the processing was done on one page but i realised that if the user presses the refresh button, the mail is sent again. I tried using header to stop cashing but that didnt work. Then I tried redirecting the user to another page once the mail has been sent but if they go back to the previous page and click refresh, it still has the same problem.What is the best way of stopping mail being sent more than once?Thanks for your help. Quote Link to comment Share on other sites More sharing options...
insrtsnhere13 Posted April 21, 2006 Share Posted April 21, 2006 I would say set a session or a cookie whenever the mail is sent, and then in your sendmail.php or whatever, add a check to see if the cookie or session is set, obviously, if it is, give them an error, if it isnt, send the mail. that should work. but obviously there are ways around it still Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 21, 2006 Share Posted April 21, 2006 Best idea i came up with so far was to use a <div> along with ajax, which submits the data to the php script via an xml http request, and then hides the div which contains the form.As the form data is sent via an image onClick event, without actually pressing "submit" refreshing the page doesnt generate the problem you described, it just presents you with an empty form again. I can't give you an example of the code though, as its not on my PC here at work, its at home. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.