I am trying to make a discussion forum where people ask questions and other reply. I am also trying to make a provision where people can reply to a reply(like that in facebook). But when I am trying add the reply id to the table of reply-to-a-reply, every time the reply id goes 0. I tried to echo the reply id, it shows me the correct id but whenever I am trying to add it to the database the reply id goes 0. I am passing the id of a reply id as follows:
while($reply=mysql_fetch_array($rep))
{
$rid=$reply['rid'];
echo "<form method='POST'>";
$e=$reply['email'];
$rid=$reply['rid'];
echo "<input type='hidden' value='$e' name='report_user'>";
echo "<input type='hidden' value='$rid' name='report_id'>";
$q="SELECT fname,lname FROM register WHERE email='$e'";
$sql=mysql_query($q);
$r=mysql_fetch_array($sql);
echo "<b>".$r[0]." ".$r[1]." - </b>".$reply['reply']." <input type='submit' formaction='report.php' value='X' title='Report Post' class='imgR' name='sub'>";
if($e!=$email)
echo "<input type='submit' name='reply_t' formaction='r.php' value='Reply' title='reply' class='imgRl' name='sub'><input type='hidden' name='rid' value='$rid'><br><br>";
Now the reply-to-a-reply goes by pressing the button "Reply" as a formaction to 'r.php'. r.php receives reply id as follows:
$rid=$_REQUEST['rid'];
$reply=$_REQUEST['reply'];
$email=$_SESSION['email'];
if(empty($reply))
$flag=0;
else{
$query="INSERT INTO reply VALUES('','$reply','$email','$rid','')";
mysql_query($query);
$flag=1;
}
Please tell me what to rectify here