PHP Form Message

后端 未结 4 1657
逝去的感伤
逝去的感伤 2021-01-23 03:16

So I have a form:

相关标签:
4条回答
  • 2021-01-23 03:19

    Instead of isset use simply if

    Like this

    <?php
     if ($sent_mail) {
     echo 'Thank you. We will be in touch soon.';
     }
    else
     echo 'Unale to send message';
     ?>
    
    0 讨论(0)
  • 2021-01-23 03:19

    You are assigning Boolean to $sent_mail and you set it to True.

    <?php if($sent_mail){
    echo "Email sent successfully";} ?>
    
    0 讨论(0)
  • 2021-01-23 03:36

    mail function returns a boolean (true/false), so you can do like this

    if (mail('myemail.co.uk', $email, $message)) {
        echo "Thank you. We will be in touch soon.";
    } else {
        echo "Something went wrong, the email was not sent!";
    }
    

    Also, the structure of mail (the parameters) are to-address, subject, message. Which means that your current subject is the email-address, I'm not sure if this is what you intended?

    0 讨论(0)
  • 2021-01-23 03:40

    Use

    if(mail('myemail.co.uk', $email, $message))
        $sent_mail = true;
    else
        $sent_mail = false;
    

    And finally:

    <?php
     if ($sent_mail) {
     echo 'Thank you. We will be in touch soon.';
     }
    else
     echo 'Message cannot be send';
     ?>
    
    0 讨论(0)
提交回复
热议问题