我在网站上有一个联系表单,用户可以在其中向网站所有者发送消息。它的联系方式是
<form class="form" id="form1" action="send_form_email.php" method="post">
<p class="name">
<input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Name" id="name" />
</p>
<p class="phone">
<input name="phone" type="text" class="validate[required,custom[email]] feedback-input" id="phone" placeholder="Phone Number" />
</p>
<p class="email">
<input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" />
</p>
<p class="businessname">
<input name="business_name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Business Name" id="name" />
</p>
<p class="text">
<textarea name="comment" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Comment"></textarea>
</p>
<div class="submit">
<input type="submit" name="submit" value="Submit!" id="button-blue"/>
<div class="ease"></div>
</div>
</form>
send_form_email.php的编码为:
<?php
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$business_name = $_POST['business_name'];
$comment = $_POST['comment'];
$from = 'From: website.com'; //url of contact form or website
$to = 'user@gmail.com'; //my email id
$subject = 'Customer Inquiry';
$body = "From: $name'n Phone: $phone'n E-Mail: $email'n Business Name: $business_name'n Message:'n $message";
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-type: text/html'r'n";
$headers = 'From: from@example.com' . "'r'n" .
'Reply-To: reply@example.com' . "'r'n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header( "Location: index.html" );
?>
问题是,它在第6行(即$comment = $_POST['comment'];
)显示了一个错误,称Parse error:语法错误,在第6 行的/nfs/c11/h01/mnt/193678/domains/website.com/html/admin/send_form_email.php中出现意外的T_STRING
EDIT: 1
我已经删除了由于服务器问题引起的错误。。但现在的错误是,当邮件发送给管理员时,邮件中的消息是空白的,我希望在邮件中接收姓名、电子邮件、电话号码、业务和评论
将$body
更改为类似的消息
$message = "From: $name'n Phone: $phone'n E-Mail: $email'n Business Name: $business_name'n Message:'n ";