0

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"; 	  
								  }
	                       }
	               }
         }
?>
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rEhSi_123
0

Assuming that you have a login module, it should be setting a Session variable for the user to indicate that he/she is properly logged in. You need to check this variable anywhere that you have functions that require a login. You may, in fact want to make this more than an on/off switch. You may want to have users with different levels of authority. You might have a moderator who has more authority than a normal user but not as much as the system administrator.

0

Many forums are available on net, take them and customize them, they required minor layout changes and use them

0

Assuming that you have a login module, it should be setting a Session variable for the user to indicate that he/she is properly logged in. You need to check this variable anywhere that you have functions that require a login. You may, in fact want to make this more than an on/off switch. You may want to have users with different levels of authority. You might have a moderator who has more authority than a normal user but not as much as the system administrator.

Thanks Chris!

Yes I have a login module!

Could you please elaborate your technique........please.

Thanks

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.