I am currently creating a forum system and have gone completely blank as how to fix this issue!
The issue is as follows:
A topic is created. A user comes along and comments on the topic and message is posted on the thread. Right!
Now another user comes along and views the topic and sees that there is a comment left by a user. So, user decides to reply to this comment not directly related to the topic and clicks on 'reply now'.
Anyways onces the types in the message to this comment he clicks on the button 'reply now'.
So, now when the message is posted on the thread, there are two messages, both from a different user.
My plan is to put the old message into a box or quote box and have the old message below which I am unable to acheive.
here is the page where the user types in the message:
Code: Select all
<?php
if(!$_SESSION['uid']){
header("Location: index.php");
}
$msg = mss($_POST['reply']);
$tid = mss($_GET['id']);
$reply_id = $_GET['reply_id'];
$id = $_GET['id'];
if($tid){
echo $reply_id;
$sql = "SELECT * FROM `forum_topics` WHERE `id`='".$tid."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "This topic does not exist!";
}else {
$sql = "SELECT * FROM `forum_replies` WHERE `id`='".$reply_id."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
$text = $row['message'];
if(!$_POST['submit']){
echo "<form method=\"post\" action=\"./index.php?act=test&id=".$row['tid']."&reply_id=".$reply_id."\">\n";
echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n";
echo "</table>\n";
echo "</table>\n";
}else{
if($row2['admin'] == 1 && $admin_user_level == 0){
echo "You do not have sufficient priveleges to add a reply to this topic";
}else {
if(!$msg){
echo "You did not supply a reply";
}else {
if(strlen($msg) < 10 || strlen($msg) > 10000){
echo "Your reply must be between 10 and 10,000 characters!";
}else {
$date = date("d-m-y") ." at ". date("h-i-s");
$time = time();
$sql4 = "INSERT INTO `forum_replies` (`tid`,`uid`,`message`,`date`,`time`,`reply_id`) VALUES('".$tid."','".$_SESSION['uid']."','".$msg."','".$date."','".$time."','".$reply_id."')";
$res4 = mysql_query($sql4) or die(mysql_error());
header("Location: ./index.php?act=topic&id=".$tid);
}
}
}
}
}
}
?>
Code: Select all
<?php
if(!$_SESSION['uid']){
header("Location: index.php");
}
$tid = mss($_GET['id']);
$msg = mss($_POST['reply']);
if(!$tid){
echo "You did not supply a topic to add a reply to";
}else {
$sql = "SELECT * FROM `forum_topics` WHERE `id`='".$tid."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "This topic does not exist";
}else {
$row = mysql_fetch_assoc($res);
$sql2 = "SELECT admin FROM `forum_sub_cats` WHERE `id`='".$row['cid']."'";
$res2 = mysql_query($sql2) or die(mysql_error());
$row2 = mysql_fetch_assoc($res2);
if(!$_POST['submit']){
echo "<form method=\"post\" action=\"./index.php?act=reply&id=".$row['id']."\">\n";
echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:90%;height:200px\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" stlye=\"width:90%\"></td></tr>\n";
echo "</table>\n";
}else{
if($row2['admin'] == 1 && $admin_user_level == 0){
echo "You do not have sufficient priveleges to add a reply to this topic";
}else {
if(!$msg){
echo "You did not supply a reply";
}else {
if(strlen($msg) < 10 || strlen($msg) > 10000){
echo "Your reply must be between 10 and 10,000 characters!";
}else {
$date = date("d-m-y") ." at ". date("h-i-s");
$time = time();
$sql3 = "INSERT INTO `forum_replies` (`tid`,`uid`,`message`,`date`,`time`) VALUES('".$tid."','".$_SESSION['uid']."','".$msg."','".$date."','".$time."')";
$res3 = mysql_query($sql3) or die(mysql_error());
$sql4 = "UPDATE `forum_topics` SET `time`='".time()."' WHERE `id`='".$tid."'";
$res4 = mysql_query($sql4) or die(mysql_error);
header("Location: ./index.php?act=topic&id=".$tid);
}
}
}
}
}
}
?>
Please Help....
Thanks