在我的网站上,我有一个reportpost.php代码段。我已经对其进行了设置,以便当您单击报告按钮时,将启动此代码。在电子邮件部分,我没有收到帖子的内容。
<?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 = "[email protected]";
$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 = "[email protected]";
$headers = "From: $from";
mail($to1,$subject,$message,$headers);
mail($to2,$subject,$message,$headers);
header("location:http://www.ecer.ca/myposts/?msg=1");
exit();
?>
您的代码逻辑中存在问题,我认为这可以解决您的问题:
<?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 = "[email protected]";
$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 = "[email protected]";
$headers = "From: $from";
mail($to1,$subject,$message,$headers);
mail($to2,$subject,$message,$headers);
header("location:http://www.ecer.ca/myposts/?msg=1");
exit();
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句