dongyi5070 2015-12-21 01:50
浏览 138
已采纳

PHP抓取内容 - 电子邮件

On my website, I have a reportpost.php piece of code. I have set it up so that when you click the report button, this code launches. In the e-mail part, I don't get the posts content.

<?php 

session_start();

$con = mysql_connect("---","---","---");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("ecerca", $con);

//$result = mysql_query("SELECT Content FROM Entries ORDER BY id");
$result  = mysql_query("SELECT * FROM Posts WHERE Username='$_SESSION[Username]' ORDER BY ID");

mysql_close($con);

$row  = mysql_fetch_array($result);

while ($row = mysql_fetch_array($result))
{

if ($row['ID'] == $_GET['id']){
  echo "$row[Content]";
}
}

$to1 = "ecerserver@outlook.com";
$subject = "Reported Post | Ecer Forums";

$message = "Someone has reported a post on Ecer Forums!



This is a message to inform you that


Username: '" . $usr . "' 


 has reported the following post: '" . $row['Content'] . "'";

$from = "admin@ecer.ca";
$headers = "From: $from";
mail($to1,$subject,$message,$headers);
mail($to2,$subject,$message,$headers);

header("location:http://www.ecer.ca/myposts/?msg=1");

exit();

?>
  • 写回答

1条回答 默认 最新

  • dsft8327 2015-12-21 01:56
    关注

    there's a problem in the logic of your code, I think this will solve your problem:

    <?php 
    
    session_start();
    
    $con = mysql_connect("---","---","---");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db("ecerca", $con);
    
    //$result = mysql_query("SELECT Content FROM Entries ORDER BY id");
    $result  = mysql_query("SELECT * FROM Posts WHERE Username='$_SESSION[Username]' ORDER BY ID");
    
    mysql_close($con);
    
    $row  = mysql_fetch_array($result);
    
    if (! $row)
    {
        exit();
    }
    
    if ($row['ID'] == $_GET['id']){
      echo "$row[Content]";
    }
    
    $to1 = "ecerserver@outlook.com";
    $subject = "Reported Post | Ecer Forums";
    
    $message = "Someone has reported a post on Ecer Forums!
    
    
    
    This is a message to inform you that
    
    
    Username: '" . $usr . "' 
    
    
     has reported the following post: '" . $row['Content'] . "'";
    
    $from = "admin@ecer.ca";
    $headers = "From: $from";
    mail($to1,$subject,$message,$headers);
    mail($to2,$subject,$message,$headers);
    
    header("location:http://www.ecer.ca/myposts/?msg=1");
    
    exit();
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码