Jump to content

Archived

This topic is now archived and is closed to further replies.

wardo

Stopping mail being sent more than once.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.