bpat1434;10908120 wrote:So what's the question? Rename reply.php to reply-process.php and make reply.php the destination when someone clicks the reply button.
Or, the easier thing is to just modify reply.php to show an input form when $_POST is empty instead of echoing an error message.
Mate thanks for your advice.....everything is working fine.
Now I have another issue, where I am trying to reply to a comment instead to the topic posted. In other terms nested replies.
I have a reply_id in my forum_replies which is NULL if it is a reply to the topic and in other case store the ID of the comment to which a reply is been made.
something like this:
forum_replies
id - tid - uid - message - date - time - edit_time - reply_id
33 10 4 hey 20/03/2009 1237593182 0 NULL
34 10 6 hey yourself 21/03/2009 1237563999 0 33
So therefore I have to know the ID of the post so that it is inserted into the reply_id.........and assign a new ID to the reply as shown above.
I have adjusted my code as posted below but I am still confused with the SQL side.......could you please shed some light:
<?php
if(!$_SESSION['uid']){
header("Location: index.php");
}
//if(!$_POST['submit']){
// echo "Invalid usage of file";
//}else {
$msg = mss($_POST['reply']);
$tid = mss($_GET['id']);
if($tid){
$tid = mss($_GET['id']);
$sql = "SELECT * FROM `forum_replies` 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);
if(!$_POST['submit']){
echo "<form method=\"post\" action=\"./index.php?act=test&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();
$sql4 = "INSERT INTO `forum_replies` (`tid`,`uid`,`message`,`date`,`time``reply_id`) VALUES('".$tid."','".$_SESSION['uid']."','".$msg."','".$date."','".$time."','".$reply_id."')";
$res4 = mysql_query($sql3) or die(mysql_error());
header("Location: ./index.php?act=topic&id=".$tid);
}
}
}
}
}
}
?>