使用PHP发送未显示收件箱中所有填写表格的邮件

时间:2018-07-05 12:55:29

标签: php forms email

我对此很陌生。我一直在与某人合作解决此问题,即将某邮件从HTML表单发送到我的收件箱,并希望在我的收件箱中显示已填充的输入内容,并在收件箱中显示其他消息。

index.html

<form action="mail.php" method="post">
    <section id="left">
        <label for="form_name">Name</label>
        <input name="form_name" id="form_name" type="text" >
        <label for="form_email">Email</label>
        <input name="form_email" id="form_email" type="email" >
        <label for="form_msg">Message</label>
        <textarea name="form_msg" id="form_msg"></textarea>
        <input id="submit" class="button" name="submit" type="submit" value="send">
    </section>
</form>

mail.php

<?php
if($_POST){
    $name = $_POST['form_name'];
    $email = $_POST['form_email'];
    $message = $_POST['form_msg'];
    $phone = $_POST['phone_no'];
    //send email
    mail("myemail@gmail.com", "This is a Reservation  from:" ,Name. ':' . $name, $email, $phone);
    }
?>

mail.js

$.ajax({
   type: "POST",
   url: "email.php",
   data: $(form).serialize(),
   success: function(){
   $('.success').fadeIn(1000);
   }
});

1 个答案:

答案 0 :(得分:0)

mail("kondasmajid@gmail.com", "This is a Reservation  from:" ,Name. ':' . $name, $email, $phone);

...那条线将无处可去。在PHP中,您必须通过点将字符串连接起来,因此以下行应该起作用:

mail("kondasmajid@gmail.com", 
  "This is a Reservation  from: Name:" . $name . ", Email: " . $email . ", Phone: " . $phone);