doushu8260
2016-03-13 22:24
浏览 34
已采纳

当我提交联系表格时,apache没有显示任何内容

I know there are similar people that posted contact form help but I have an issue with mine. Everything works but when I submit I get an e-mail from apache that shows a blank message. However, when I use my own e-mail address in the form input , it works.

Here is my code

<?php 
if(isset($_POST['submit'])){}
$name = $_POST['name'];
$email = $_POST['email'];
$minrooms=$_POST['mrooms'];
$message = $_POST['comment'];
$formcontent="From: $name 
 Email: $email 
 Min Number of Rooms: $minrooms
 Message: $message ";
$recipient = "kellito13@gmail.com";
$subject = "Contact Form";
$mailHeader = "From: $email 
";
send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");
echo "Thank You!";
}
else{
    echo"Error";
}
?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duankuan5319 2016-03-13 22:39
    已采纳

    You have syntax errors in your code with {} and send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");.

    It should be something like this:

    <?php
    if(isset($_POST['submit'])){
        $name = $_POST['name'];
        $email = $_POST['email'];
        $minrooms=$_POST['mrooms'];
        $message = $_POST['comment'];
        $formcontent="From: $name 
     Email: $email 
     Min Number of Rooms: $minrooms
     Message: $message ";
        $recipient = "kellito13@gmail.com";
        $subject = "Contact Form";
        $mailHeader = "From: $email 
    ";
        $send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");
        echo "Thank You!";
    }
    else{
        echo"Error";
    }
    ?>
    
    点赞 打赏 评论

相关推荐 更多相似问题