PHP email form sends email everytime page is refreshed

后端 未结 3 999
半阙折子戏
半阙折子戏 2021-01-17 06:11

my php email for is sending emails every time the page is refreshed. For example the user is filling out the form and sending it with the send button. That\'s all fine and g

3条回答
  •  情深已故
    2021-01-17 06:59

    You should use different files, at different URLs to handle the actions:

    • send email
    • display confirmation page

    For example:

    In your form

    In sendmail.php

    // same code as above except:
    if(!$mail->Send()) {
        header("Location: success.php");
    } else {
        header("Location: error.php");
    }
    

    See the doc for details.

    In success.php

    Oh yeah ;)

    In error.php

    Ooops :(

提交回复
热议问题