PHP联系表单错误,我无法找到

时间:2015-04-19 21:14:40

标签: php html forms contact

有人可以帮我吗? 我根本无法找到问题。 邮件就不会去了。

HTML:

<form action="mail.php" method="post" enctype="text/plain">
<div class="span_of_2">
<div class="span2_of_1">
<h4>Name:</h4>
<div class="book_date btm">

<input class=""  type="text" placeholder="Name" name="name">

</div>
<h4>Check in:</h4>
<div class="book_date btm">

<input name="checkin" class="date" id="datepicker1" type="text" value="DD/MM/YY" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'DD/MM/YY';}">

</div>  
<div class="sel_room">
<h4>Apartment:</h4>
<select id="country" onchange="change_country(this.value)" class="frm-field required" name="apartment">
<option value="null">Pick an apartment:</option>
<option value="1">Small apartment</option>         
<option value="2">Big apartment</option>
</select>
</div>  
<div class="sel_room left">
<h4>Adults:</h4>
<select id="country" onchange="change_country(this.value)" class="frm-field required" name="persons">
<option value="1">1</option>
<option value="2">2</option>         
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>  
</div>
<div class="span2_of_1">
<h4>e-mail</h4>
<div class="book_date btm">

<input class=""  type="text" placeholder="e-mail" name="email">

</div>
<h4>Check out:</h4>
<div class="book_date btm">

<input name="checkout" class="date" id="datepicker" type="text" value="DD/MM/YY" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'DD/MM/YY';}">

</div>      
<div class="sel_room">
<h4>Children:</h4>
<select id="country" onchange="change_country(this.value)" class="frm-field required" name="kids">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>         
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>  

</div>
<div class="clear"></div>
</div>
<div class="res_btn" style="margin:0 auto;">

<input type="submit" value="Make reservation" style="background: #32A2E3; height: 50px; font-size: 20px; font-family: 'Open Sans', sans-serif;" name="send">

</div>
</form> 

PHP:

<?php 

if (isset($_POST["send"])){

$Name = $_POST["name"];
$Email = $_POST["email"];
$Checkout = $_POST["checkout"];
$Checkin = $_POST["checkin"];
$Apartment = $_POST["apartment"];
$Persons = $_POST["persons"];
$Kids = $_POST["kids"];

$To = "jurica.mlinaric@gmail.com"; // this is your Email address
$Subject = "Apartmani Costa Rica";
$Message = "From : $Name"; 
$Headers = $Email;
mail($To, $Subject, $Message);
echo "Email Sent.";

}

?>

我真的不知道问题是什么。它是一个简单的html联系表单。我的服务器是,但它不会发送它。

1 个答案:

答案 0 :(得分:-2)

替换此部分:

$Headers = $Email;
mail($To, $Subject, $Message);

有了这个:

$Headers  = "MIME-Version: 1.0\r\n";
$Headers .= "Content-type: text/html; charset=UTF-8\r\n";
$Headers .= "From: ". $Name;
mail($To, $Subject, $Message, $Headers);