douhao5280 2013-02-08 07:47
浏览 60

使用PHP输出内容发送邮件不会显示在收件箱中

I have Forgot Password Form where users can enter their valid email address. I have no problem in sending mail to user, my only problem is that i want to send to users their account information from database (Username & Password )so that they will know their username and password. But it seems like I'm having hard time on how to display their account information on the user's inbox. I'm new in PHP and it would be great if you could help me on how to figure it out.

Here's my code:

Edited:

<?php
if (isset($_POST['submit'])) {
    $email_from = "example@domain.com";
    $datesent = date('D m/d/Y, g:i A');
    $error_message = "";
    $msg = "";
    $subject = "Some text here";


    //some validations here

    $query = "Select * from user_information where EMAIL_ADDRESS = '".$_POST['email']."'";
    $result = mysql_query($query) or die("ERROR: ".mysql_error());
    $check = mysql_num_rows($result);
    if ($check == 0) {
        $row = mysql_fetch_assoc($result);
        $username = $row['USERNAME'];
        $password = $row['PASSWORD'];
        $fname = $row['FIRST_NAME'];
    }
    ob_start(); //Turn on output buffering
?>

    Hi <? php echo $fname; ?>!

        Here is your Account information:

        Username: <? php echo $username; ?>
        Password: <? php echo $password; ?>

    //some text here

<?php
    $message = ob_get_contents();
    ob_get_clean();
    $email_message = "From: ".clean_string($email_from)."
";
    $email_message. = "Sent: ".clean_string($datesent)."
";
    $email_message. = "Subject: ".clean_string($subject)."
";
    $email_message. = "
".clean_string($message)."
";
    $headers = 'From: '.$email_from."
";
    $headers. = 'To: '.$email."
";
    $headers. = 'Sent: '.$datesent."
";
    $email_sent = @mail($sendto, $subject, $email_message, $headers);
} ?>
  • 写回答

4条回答 默认 最新

  • dswfyq6201 2013-02-08 07:56
    关注

    The following code does not work fpr you:

    $check = mysql_num_rows($result);
    if($check==0){
        ...
     }
    

    should be:

    $check = mysql_num_rows($result);
    if($check != false){
        ...
     }
    

    You only set the username, password and fname if there is no resulting row

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP