douju5062 2013-08-19 18:08
浏览 45
已采纳

Reply-To标题没有选择php变量

I am creating a page that sends the response from contact form within mail but reply-to is not working (the variable i am using is having value, but is not added within headers)

here's my code:

<?php

//$uname=$_REQUEST['uname'];
if(isset($_REQUEST['name']))
{
    $name=$_REQUEST['name'];
}

if(isset($_REQUEST['email']))
{
    $email=$_REQUEST['email'];
}   

if(isset($_REQUEST['phone']))
{
    $phone=$_REQUEST['phone'];
}

if(isset($_REQUEST['message']))
{
    $message=$_REQUEST['message'];
}

// TESTING IF VARIABLES HAVE VALUES
echo "$name $email $phone $message";
// RESULT: TRUE TILL HERE


if($name=="" || $email=="" || $phone=="" || $message=="")
{
    header("location:../?inst=invalid");    
}
else
{

    // ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to="mail@example.com";

// Your subject
$subject="$name Contacted you via Contact Form";

// From
$headers  = "From: ME <no-reply@example.com>
";
$headers .= 'Reply-To:' . $email . "
";
$headers .= "Return-Path: info@example.com
";
$headers .= "X-Mailer: PHP
";
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
"; 

print $message;
// send email
$sentmail = mail($to,$subject,$message,$headers);
//$sentmail = mail($to1,$subject,$message,$header);
}

// if your email succesfully sent
if($sentmail){
echo "Mail Sent.";
}
else {
    header("location:../landing/?status=verification-pending");
    }

?>

Now when i checked headers in my gmail, the value for $email doesn't appear in header information, Also no message is received. All I get is a blank message or may be $message is not printing anything like the same case i am facing with reply-to.

please help me a little with this. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douyaju4259 2013-08-19 18:49
    关注

    Actually there was a little mistake with the above code. I mistakenly added = instead of == while comparison.

    This line:

    if($name=="" || $email="" || $phone="" || $message="")
    

    Should read as:

    if($name=="" || $email=="" || $phone=="" || $message=="")
    

    Since = is for equation and not a condition for comparison ==

    Fixed it in the Question

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求