PHP邮件脚本给了我语法错误
我试图将我的php邮件程序嵌入到我的html页面中,我在Dreamweaver中没有发现语法错误,但是sendmail()一直给我这个错误消息“参数中的语法错误” “我希望你能帮我解决这个问题 我的PHP邮件:PHP邮件脚本给了我语法错误,php,forms,email,Php,Forms,Email,我试图将我的php邮件程序嵌入到我的html页面中,我在Dreamweaver中没有发现语法错误,但是sendmail()一直给我这个错误消息“参数中的语法错误” “我希望你能帮我解决这个问题 我的PHP邮件: //Email information $admin_email = "------------ Secret"; $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $comment = $_REQUEST['co
//Email information
$admin_email = "------------ Secret";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
这是相关的页面代码
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "schlichtingr@yahoo.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<html>
<head>
</head>
<body>
<div id ="Email">
<form method="post"><br />
<h3><b>send us a message</b></h3>
<span>Any further questions or concerns? Send us an email!</span><br>
Email: <input name="email" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="comment" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
</div>
<?php
}
?>
给我们发个信
还有什么问题吗?给我们发电子邮件
电子邮件:
主题:
消息:
如果你能给我任何帮助,我将不胜感激
我是php新手,但仍在努力学习
基本上,我只想在html页面上创建一个邮件表单我不熟悉sendmail,但我注意到一件事:
“$subject”
只需是$subject
。您捕获该变量是有原因的。所以把它变成一串“$subject”对我来说毫无意义 //if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "user@example.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
$headers = "From: $email" . "\r\n";
mail($admin_email, $subject, $comment, $headers);
//Email response
echo "Thank you for contacting us!";
}
这是一个PHP错误,还是来自PHP试图调用的smtp客户端以实际执行发送的错误?请尝试删除引号:“$subject”=>$subjectRead-up-on-这就是编写手册的目的;)就像“ol录像机”。如果没有时间,你永远无法完全弄清楚如何设置时间。你确实意识到你只是在检查
如果(isset($\u REQUEST['email'))
-如果有人没有填写主题字段,邮件很可能会被拒绝或发送到垃圾邮件中。你的代码没有问题,我测试它的时候没有。检查邮件日志,并在打开后立即将错误报告添加到文件顶部。由于邮件脚本位于同一页面中,因此不需要“操作”属性。没有动作属性,表单提交到当前页面。啊!好啊说得好。很抱歉我的php foo生锈了。将编辑出该值。“$string”
和$string
由于以下原因计算为相同的值。