How to stop form from sending email more times after initial success.

前端 未结 2 1905
北恋
北恋 2021-01-23 20:30

Can someone please show me example code or specify what i am doing wrong as solutions below have not yielded much luck for me :(
I am working on a contact f

2条回答
  •  野的像风
    2021-01-23 21:20

    You should use the post/redirect/get pattern here.

    Using this pattern advocates sending a redirect as a response from your form handling page, and as a result subsequent refreshes will not trigger these actions more than once.

    From the documentation:

    ...instead of returning a web page directly, the POST operation returns a redirection command.

    In pseudo-code, your handler page should have something like:

    • Whatever initial handling code you have
    • Send Email
    • header("Location: /someotherpage");
    • exit();

提交回复
热议问题