5

I have a problem with my contact form that I have made using HTML and PHP. When the user clicks submit it redirects to another page where the user gets the message, "Your message has been sent". It then automatically redirects to the home page. But when the user clicks the back button, the message appears again and the form is resubmitted. Consequently I get two identical messages sent to my email!

How can I fix this?

MrWhite
  • 23,175
  • 4
  • 44
  • 71
Devansh Kumar
  • 87
  • 1
  • 1
  • 8
  • 1
    When you click back you also resend form data. You would be better off to redirect the user to a new instance of the page. By giving a clickable link or just use – Christoffer Jul 07 '12 at 17:45
  • 1
    [HTTP Status Code 303: See Other](http://en.wikipedia.org/wiki/HTTP_303) – Grexis Jul 07 '12 at 17:45

1 Answers1

4

Take a look at Preventing form resubmission and Prevent Back button from showing POST confirmation alert where you will find useful info how to make redirects which won't trigger form re-submission when the Back button is clicked.

Community
  • 1
  • 1
brezanac
  • 8,750
  • 4
  • 38
  • 57