Hello all,
I have a bit of an issue, Currently I am working on a forum system.
This is the code for when a person click on a forum category.
I would like some suggestions as to how I could implement in such a way that if a non user clicks on 'create a topic' link then he/she is given a message saying please login/register to post a topic here.
Thanks
<?php
$id = mss($_GET['id']);
if($id){
$sql = "SELECT * FROM `sub_categories` WHERE `id`='".$id."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "The forum category you supplied does not exist!\n";
}else {
$row = mysql_fetch_assoc($res);
if($row['admin'] == 1 && $admin_user_level == 0){
echo "You must be an administrator to view this forum!\n";
}else {
$sql2 = "SELECT * FROM `topics` WHERE `cid`='".$row['id']."' ORDER BY time DESC";
$res2 = mysql_query($sql2) or die(mysql_error());
if(mysql_num_rows($res2) == 0){
echo "There are no topics in this forum, <a href=\"./index.php?act=create&id=".$row['id']."\">click here</a> to create a topic!\n";
}else {
echo "<table border=\"0\" cellsapcing=\"3\" cellpadding=\"3\" width=\"100%\">\n";
echo "<tr><td colspan=\"4\" align=\"right\"><a href=\"./index.php?act=create&id=".$row['id']."\"><img src=\"new.gif\"></a></td></tr>\n";
echo "<tr align=\"center\"><td class=\"forum_header\">Title</td><td class=\"forum_header\">User</td><td class=\"forum_header\">Date Created</td><td class=\"forum_header\">Replies</td></tr>\n";
while($row2 = mysql_fetch_assoc($res2)) {
$sql3= "SELECT count(*) As `num_replies` FROM `post_replies` WHERE `tid`='".$row2['id']."'";
$res3 = mysql_query($sql3) or die(mysql_error());
$row3 = mysql_fetch_assoc($res3);
echo "<tr align=\"center\"><td class=\"forum_header2\"><a href=\"./index.php?act=topic&id=".$row2['id']."\">".s($row2['title'])."</a></td><td class=\"forum_header2\">".uid($row2['uid'])."</td><td class=\"forum_header2\">".$row2['date']."</td><td class=\"forum_header2\">".$row3['num_replies']."</td></tr>\n";
}
echo "</table>\n";
}
}
}
}
?>