Php 表单显示代码中的一个错误
这是我的密码Php 表单显示代码中的一个错误,php,Php,这是我的密码 <?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 Comment
<?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.";
}
?>
从这里删除最后一个点
Comments:- " . $comments .
应该如此
Comments:- " . $comments;
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments;
现在您正在将另一行连接到$message;)
只需从行尾删除点(.),这样它就不会和下面的标题行连接。
应该是
Comments:- " . $comments;
$message =
"
Name:- " . $name . "\r\n
Email:- " . $email . "\r\n
Comments:- " . $comments;
您正在连接另一行$headers=“From:”$电子邮件。“\r\n”
到$message
字符串您的$message
声明应以结尾
,而不是
,它在末尾包含$headers
变量。