我有错误。它说:
语法错误,意外的文件结尾
<?php
{
if($_POST["submit']) {
$recipient=\"youremail@gmail.com\";
$subject=\"Inquiry Form\";
$sender=$_POST [name];
$senderEmail=$_POST [email];
$FeedbackQuestion=$_POST [feedback];
$mailBody=\"Name: $name\nEmail:$email\n\n$feedback;
\mail($recipient, $subject, $mailbody, \"From: $name<$email>\");
$thankYou=\"Thank you! Your message has been sent.\";
}
?>
问题是什么?
答案 0 :(得分:2)
将if($_POST["submit']) {
替换为if($_POST["submit"]) {
在"
'
而不是submit
然后,删除第2行的第一个{
。
完整正确的代码是:
<?php
if($_POST["submit"])
{
$recipient="youremail@gmail.com";
$subject="Inquiry Form";
$sender=$_POST ['name'];
$senderEmail=$_POST ['email'];
$FeedbackQuestion=$_POST ['feedback'];
$mailBody="Name: $name\nEmail:$email\n\n$feedback";
mail($recipient, $subject, $mailbody, "From: $name<$email>");
$thankYou="Thank you! Your message has been sent.";
}
?>
此外,所有\"
都必须替换为“因为\"
仅在"
所包围的字符串中需要。
此外,数组键必须由'
括起来。