我已经检查了其他每一个关于这个问题的帖子,但我真的无法解决这个问题。我一直在调试每一行,问题在于$body
(出现错误时)。在这段代码之前,我有一个sql查询将输入字段插入到数据库中,这完全有效。以下代码直接位于其下方。我关闭了每一个括号,每个分号使用但是错误仍然是吐出来的,我不知道为什么。有人可以帮忙吗?
$to = "example@example.com";
$subject = "New Course Application Form";
$body = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tbody>
<tr>
<td style="padding: 5px 10px;" width="150">Course: </td>
<td style="padding: 5px 10px;">$course</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Firstname: </td>
<td style="padding: 5px 10px;">$firstname</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Surname: </td>
<td style="padding: 5px 10px;">$surname</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">D.O.B: </td>
<td style="padding: 5px 10px;">$DOB</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Gender: </td>
<td style="padding: 5px 10px;">$gender</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Address Line 1: </td>
<td style="padding: 5px 10px;">$address1</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Address Line 2: </td>
<td style="padding: 5px 10px;">$address2</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">City: </td>
<td style="padding: 5px 10px;">$city</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Postcode: </td>
<td style="padding: 5px 10px;">$postcode</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Mobile Phone Number: </td>
<td style="padding: 5px 10px;">$mobile</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Home Phone Number: </td>
<td style="padding: 5px 10px;">$home</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Email Address: </td>
<td style="padding: 5px 10px;">$email</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">3 Year Residency: </td>
<td style="padding: 5px 10px;">$residency</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150">Learning Difficulties: </td>
<td style="padding: 5px 10px;">$learning</td>
</tr>
<tr>
<td style="padding: 5px 10px;" width="150"> Previous Qualifications: </td>
<td style="padding: 5px 10px;">$qualifications</td>
</tr>
</tbody>
</table>
EOD;
$headers = "From: example@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
if (mail($to, $subject, $body, $headers )) {
echo "Thank you for sending us an enquiry. We will get back to you.";
} else {
echo "Please fill in the form fields and try again";
}
header("Location: apply.php");