跟进:PHP 个变量未出现在已发送的电子邮件中
Follow Up: PHP variables not appearing in sent email
首先,对于开始另一个问题,我深表歉意,但我对之前 post (Some PHP variables not appearing when contact us form is used) 的更新没有得到回应。
我按照之前 post 中的建议提出了建议,并将文件上传到我的托管服务提供商。但是,当我尝试提交联系表时,出现了一个名为 "page save failed".
的新错误
下面是当前的php代码:
<?php
if(!$_POST) exit;
$to = 'enquiries@mydomain.com'; #Replace your email id...
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'Office enquiry from ' . $name . '.';
$msg = "You have been contacted by ".$name."\r\n\n";
$msg .= "You can contact ".$name." via email, ".$email.".\r\n\n";
$msg .= "You can call ".$name." on ".$phone.".\r\n\n";
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
$msg .= $comment."\r\n\n";
$msg .= "---------------------------------------------------------------\r\n";
if(@mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We have received your query and will be in touch soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again or contact us via live chat.</span>";
}
?>
再次抱歉开始新问题,但我将不胜感激。
首先,您的字符串连接有一些错误:
替换这部分:
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
为此:
$msg .= "$name has ". $emp ." employees and the company name is" . "$comp" . "\r\n\n";
$msg .= $name." would like to move in on " . $move . "\r\n\n";
此外,尽量避免使用 @
来抑制警告。没有它,您将能够看到 mail()
函数的任何错误。
首先,对于开始另一个问题,我深表歉意,但我对之前 post (Some PHP variables not appearing when contact us form is used) 的更新没有得到回应。
我按照之前 post 中的建议提出了建议,并将文件上传到我的托管服务提供商。但是,当我尝试提交联系表时,出现了一个名为 "page save failed".
的新错误下面是当前的php代码:
<?php
if(!$_POST) exit;
$to = 'enquiries@mydomain.com'; #Replace your email id...
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'Office enquiry from ' . $name . '.';
$msg = "You have been contacted by ".$name."\r\n\n";
$msg .= "You can contact ".$name." via email, ".$email.".\r\n\n";
$msg .= "You can call ".$name." on ".$phone.".\r\n\n";
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
$msg .= $comment."\r\n\n";
$msg .= "---------------------------------------------------------------\r\n";
if(@mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We have received your query and will be in touch soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again or contact us via live chat.</span>";
}
?>
再次抱歉开始新问题,但我将不胜感激。
首先,您的字符串连接有一些错误:
替换这部分:
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
为此:
$msg .= "$name has ". $emp ." employees and the company name is" . "$comp" . "\r\n\n";
$msg .= $name." would like to move in on " . $move . "\r\n\n";
此外,尽量避免使用 @
来抑制警告。没有它,您将能够看到 mail()
函数的任何错误。