简体   繁体   English

PHP Grab内容-电子邮件

[英]PHP Grab Content - E-mail

On my website, I have a reportpost.php piece of code. 在我的网站上,我有一段reportpost.php代码。 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!\r\n\r\n\r\n\r\nThis is a message to inform you that\r\n\r\n\r\nUsername: '" . $usr . "' \r\n\r\n\r\n 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();

?>

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!\r\n\r\n\r\n\r\nThis is a message to inform you that\r\n\r\n\r\nUsername: '" . $usr . "' \r\n\r\n\r\n 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();

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM