我正在学习 php,并且有一本书有很多示例和练习。我正在做的是关于发送电子邮件的。我将代码复制到信中,但出现错误:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\website2\www\sendscript.php on line 6
为什么会发生这种情况,有什么想法吗?
这是我的 PHP 脚本:
<?php
if(($_POST['sender_name']=="")||($_POST['sender_email']=="")||($_POST['message']=="")){
header("Location: sendemail.html");
exit;
}
$email = "Sender's name:\t$_POST['sender_name']\n";
$email .= "Sender's email:\t$_POST['sender_email']\n";
$email .= "Message:\t$_POST['message']\n";
$to = "stafford.king16@pgs.org.uk";
$subject = "did script work?";
$mailheaders = "From: Stafford King";
$mailheaders .= "Reply to: $_POST['sender_email']\n";
mail($to, $subject, $email, $mailheaders);
?>
<html>
<head></head>
<body>
<h1>Email sent!</h1>
</body>
</html>
这是我的电子邮件输入表单:
<html>
<head></head>
<body>
<form method = "post" action = "sendscript.php">
<p><strong>Your name:</strong><br />
<input type = "text" name = "sender_name" size = "30"</p>
<p><strong>Your email address:</strong><br />
<input type = "text" name = "sender_email" size = "30"</p>
<p><strong>Message:</strong><br />
<textarea name = "message" cols = "30" rows = "5" wrap = "virtual"></textarea></p>
<p><input type = "submit" name = "submit" value = "send email"></p>
</form>
</body>
</html>
多谢你们 :)