我知道有类似的人发布了联系表格帮助,但我遇到了问题。一切正常,但是当我提交时,我收到一封来自apache的电子邮件,显示一条空白消息。但是,当我在表单输入中使用我自己的电子邮件地址时,它可以工作。
这是我的代码
<?php
if(isset($_POST['submit'])){}
$name = $_POST['name'];
$email = $_POST['email'];
$minrooms=$_POST['mrooms'];
$message = $_POST['comment'];
$formcontent="From: $name \n Email: $email \n Min Number of Rooms: $minrooms\n Message: $message ";
$recipient = "kellito13@gmail.com";
$subject = "Contact Form";
$mailHeader = "From: $email \r\n";
send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");
echo "Thank You!";
}
else{
echo"Error";
}
?>
答案 0 :(得分:0)
您的代码中包含{}
和send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");
语法错误。
它应该是这样的:
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$minrooms=$_POST['mrooms'];
$message = $_POST['comment'];
$formcontent="From: $name \n Email: $email \n Min Number of Rooms: $minrooms\n Message: $message ";
$recipient = "kellito13@gmail.com";
$subject = "Contact Form";
$mailHeader = "From: $email \r\n";
$send_contact= mail($recipient, $subject, $formcontent, $mailHeader) or die("Error!");
echo "Thank You!";
}
else{
echo"Error";
}
?>