Jump to content


Stopping mail being sent more than once.

  • Please log in to reply
2 replies to this topic

#1 wardo

  • Members
  • PipPip
  • Member
  • 20 posts

Posted 21 April 2006 - 10:50 AM


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.

#2 insrtsnhere13

  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 21 April 2006 - 10:57 AM

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

#3 wisewood

  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 21 April 2006 - 11:26 AM

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.
wisewood: proven fact, I am both wise, and wooden.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users