Jump to content

Stopping mail being sent more than once.


wardo

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.