根据我的了解,我的contact.html文件以及我的_contact.php文件中的所有内容都是正确的,但由于某种原因,我一直收到Chrome错误消息“...可能已关闭或配置不正确”
这是代码,感谢任何帮助。
contact.html中的联系表单:
<div class="ctext5">
<br />
<form id="form1" name="form1" method="post" action="_contact.php">
<table width="557" border="0" cellspacing="10">
<tr>
<th width="234" scope="row"><label for="firstname">First Name:</label></th>
<td width="545"><input type="text" name="firstname" id="firstname" /></td>
</tr>
<tr>
<th scope="row"><label for="lastname">Last Name:</label></th>
<td><input type="text" name="lastname" id="lastname" /></td>
</tr>
<tr>
</tr>
<tr>
<th scope="row"><label for="_email">E-Mail:</label></th>
<td><input type="text" name="_email" id="_email" /></td>
</tr>
<tr>
<th scope="row"><label for="address">Address:</label></th>
<td><input type="text" name="address" id="address" /></td>
</tr>
<tr>
<th scope="row"><label for="cityzip">City/Zip:</label></th>
<td><input type="text" name="cityzip" id="cityzip" /></td>
</tr>
<tr>
<th scope="row"><label for="phone">Phone #:</label></th>
<td><input type="text" name="phone" id="phone" /></td>
</tr>
<tr>
<th height="85" scope="row"><label for="comments">Questions / Other Information</label></th>
<td><textarea name="comments" id="comments" cols="35" rows="5"></textarea></td>
</tr>
</table>
<input name="Submit" type="submit" value="Submit" />
</form>
</div>
_contact.php的代码:
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$_email = $_POST['_email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$cityzip = $_POST['cityzip'];
$comments = $_POST['comments'];
$headers = "MIME-Version: 1.0\r\n";
$headers = "From: $_email";
$to = 'email@domain.com';
$subject = 'Accurate Solutions Contact Form Submitted';
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n
mail($to, $subject, $message, $headers);
?>
答案 0 :(得分:7)
您没有关闭$message
字符串。试试这个:
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n"; //here the last double quote and the semicolon!
mail($to, $subject, $message, $headers);
答案 1 :(得分:1)
解析错误
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n
mail($to, $subject, $message, $headers);
?>
应该是
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n";
mail($to, $subject, $message, $headers);
?>
答案 2 :(得分:0)
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n";
mail($to, $subject, $message, $headers);
?>
您错过了“;在邮件末尾