这是我的代码
<?php
$email=$_POST['email'];
$name=$_POST['name'];
$comments=$_POST['comments'];
$to = "my@address.com";
$subject = "Comments";
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments .
$headers = "From:" . $email . "\r\n";
if(@mail($to,$subject,$message,$headers))
{
print "<script>document.location.href='http://thesite.org/docs/tkx.html';</script>";
}
else
{
echo "Error! Please try again.";
}
?>
但由于我无法检测到的原因,当数据传送到我的电子邮件时,其中包含“评论”数据末尾的“电子邮件地址”数据
我做错了什么?
提前致谢。 OzWaz
答案 0 :(得分:2)
从此处删除最后一个点
Comments:- " . $comments .
所以它应该是
Comments:- " . $comments;
现在你将另一行连接到$ message;)
答案 1 :(得分:1)
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments .
只需从行尾删除点(。),使其不与下面的标题行连接。 它应该是
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments;
答案 2 :(得分:0)
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments;
$headers = "From:" . $email . "\r\n";
您正在将另一行$headers = "From:" . $email . "\r\n";
引入$message
字符串