rEhSi_123 Posted March 30, 2009 Share Posted March 30, 2009 I have a issue with displaying wether a ADMIN or a USER on my forum. If a user is ADMIN then it displays the user as ADMIN but if the user isn't an ADMIN it still displays it as ADMIN which I dont want. Could somebody please check my code. This part of the code display the ADMIN or USER text: <?php $row2 = mysql_fetch_assoc($res2); if($row2['admin'] == 1 && $admin_user_level == 0){ echo "You cannot view this topic!"; }else { $a = (isa($row['uid'])) ? "<font style=\"color:#800000;font-weight:bold;\">ADMIN</font>" : "<font style=\"color:#333300;font-weight:bold;\">USER</font>"; echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); ?> and this is my whole code: <?php error_reporting(E_ALL ^ E_NOTICE); //Report all error except NOTICES $id = mss($_GET['id']); $page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; $page = ceil($page); $limit = 10; $start = $limit; $end = $page*$limit-($limit); if($id){ $sql = "SELECT * FROM `forum_topics` WHERE `id`='".$id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This topic does not exists!"; }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($row2['admin'] == 1 && $admin_user_level == 0){ echo "You cannot view this topic!"; }else { $a = (isa($row['uid'])) ? "<font style=\"color:#800000;font-weight:bold;\">ADMIN</font>" : "<font style=\"color:#333300;font-weight:bold;\">USER</font>"; echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); echo "</td>\n"; echo "</tr>\n"; $amount_check = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."'"; $amount_check_res = mysql_query($amount_check) or die(mysql_error()); $amount_count = mysql_num_rows($amount_check_res); $pages = ceil($amount_count/$limit); $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page-1)."\">« Prev</a>"; $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page+1)."\">Next »</a>"; echo "<tr><td align=\"right\" colspan=\"2\" class=\"forum_header\">\n"; echo "Pages: "; echo $previous; for($i=1;$i<=$pages;$i++){ $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=topic&id=".$id."&page=".$i."\">".$i."</a> "; echo $href; } echo $nextpage; echo "</td></tr>\n"; $select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; $select_res = mysql_query($select_sql) or die(mysql_error()); while($rowr = mysql_fetch_assoc($select_res)){ echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted on: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'],true)."<br>Post Count: ".post($rowr['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($rowr['message']); if($rowr['edit_time'] > 0){ echo "<tr><td align=\"left\" colspan=\"3\" class=\"forum_header\"><em>Edited at:".date("l jS \of F Y",$rowr['edit_time']) . " at " . date("h:i:s",$rowr['edit_time'])."</em></td></tr>\n"; } $adminz = isa($_SESSION['uid']); if($adminz == 1 || $rowr['uid'] == $_SESSION['uid'] || $admin_user_level == 0){ echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=reply&id=".$rowr['id']."\"><img src=\"edit.gif\"></a> <a href=\"index.php?act=test&id=".$rowr['tid']."&reply_id=".$rowr['id']."\"><img src=\"quoteIcon.gif\"></a></td></tr>\n"; } echo "</td>\n"; echo "</tr>\n"; } echo "<tr><td colspan=\"2\" align=\"left\"><a href=\"./index.php?act=reply&id=".$row['id']."\">Reply Now</a></td></tr>\n"; echo "</table>\n"; } } }else { echo "Please view a valid topic!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/ Share on other sites More sharing options...
premiso Posted March 30, 2009 Share Posted March 30, 2009 I fail to see where $admin_user_level is being defined. If it is not defined then it will never equal 0 and hence it always defaults to the else statement. Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-796853 Share on other sites More sharing options...
rEhSi_123 Posted March 30, 2009 Author Share Posted March 30, 2009 I fail to see where $admin_user_level is being defined. If it is not defined then it will never equal 0 and hence it always defaults to the else statement. Thanks mate for the reply! Could you please explain by what you mean.....please! Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-797186 Share on other sites More sharing options...
rEhSi_123 Posted March 31, 2009 Author Share Posted March 31, 2009 Anybody with further suggestions please!!!!! I did the following test by adding this bit of the code: <?php echo "POST_ADMIN: " . $row2['admin'] . "<br>"; echo "ADMIN_USER: $admin_user_level<br>"; if($row2['admin'] == 1 && $admin_user_level == 0) ?> The following values were acheived when user was logged in as a ADMIN POST_ADMIN: 0 ADMIN_USER: 1 and the following values when user was logged in as a USER POST_ADMIN: 0 ADMIN_USER: 0 Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798235 Share on other sites More sharing options...
rEhSi_123 Posted April 1, 2009 Author Share Posted April 1, 2009 BUMP Anybody! Please Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798776 Share on other sites More sharing options...
PHP Monkeh Posted April 1, 2009 Share Posted April 1, 2009 The problem is you aren't assigning any value to $admin_user_level (as premiso has already said). We can't really help you as we don't know where this value is meant to come from either. Is it a value in your forum_sub_cats table or users table? Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798780 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 BUMP Anybody! Please try this for now //if(($row2['admin'] == 1) && ($admin_user_level == 0)) if($admin_user_level !== 1) { echo "You cannot view this topic!"; } else { $a = (isa($row['uid'])) ? "<font style { echo "You cannot view this topic!"; } else { .............................. tell me if that dose it Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798798 Share on other sites More sharing options...
rEhSi_123 Posted April 1, 2009 Author Share Posted April 1, 2009 BUMP Anybody! Please try this for now //if(($row2['admin'] == 1) && ($admin_user_level == 0)) if($admin_user_level !== 1) { echo "You cannot view this topic!"; } else { $a = (isa($row['uid'])) ? "<font style { echo "You cannot view this topic!"; } else { .............................. tell me if that dose it Thanks mate for you help..... I added the above to my code^^ but it tells me a phrase error on line 49! This is line 49.....starting from else{ else{ echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); echo "</td>\n"; echo "</tr>\n"; Heres all the code <?php error_reporting(E_ALL ^ E_NOTICE); //Report all error except NOTICES $id = mss($_GET['id']); $page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; $page = ceil($page); $limit = 10; $start = $limit; $end = $page*$limit-($limit); if($id){ $sql = "SELECT * FROM `forum_topics` WHERE `id`='".$id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This topic does not exists!"; }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(!$admin_user_level == 1) { echo "You cannot view this topic!"; } else { $a = (isa($row['uid'])) ? "<font style=\"color:#800000;font-weight:bold;\">ADMIN</font>" : ""; { echo "You cannot view this topic!"; } else{ echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); echo "</td>\n"; echo "</tr>\n"; $amount_check = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."'"; $amount_check_res = mysql_query($amount_check) or die(mysql_error()); $amount_count = mysql_num_rows($amount_check_res); $pages = ceil($amount_count/$limit); $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page-1)."\">« Prev</a>"; $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page+1)."\">Next »</a>"; echo "<tr><td align=\"right\" colspan=\"2\" class=\"forum_header\">\n"; echo "Pages: "; echo $previous; for($i=1;$i<=$pages;$i++){ $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=topic&id=".$id."&page=".$i."\">".$i."</a> "; echo $href; } echo $nextpage; echo "</td></tr>\n"; $select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; $select_res = mysql_query($select_sql) or die(mysql_error()); while($rowr = mysql_fetch_assoc($select_res)){ echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted on: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'],true)."<br>Post Count: ".post($rowr['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($rowr['message']); if($rowr['edit_time'] > 0){ echo "<tr><td align=\"left\" colspan=\"3\" class=\"forum_header\"><em>Edited at:".date("l jS \of F Y",$rowr['edit_time']) . " at " . date("h:i:s",$rowr['edit_time'])."</em></td></tr>\n"; } $adminz = isa($_SESSION['uid']); //if($adminz == 1){ // echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=topic&id=".$rowr['id']."\" onclick=\"return confirm('Are you sure you want to delete?')\"><img src=\"delete.gif\"></a></td></tr>\n"; //} if($adminz == 1 || $rowr['uid'] == $_SESSION['uid'] || $admin_user_level == 0){ echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=reply&id=".$rowr['id']."\"><img src=\"edit.gif\"></a> <a href=\"index.php?act=test&id=".$rowr['tid']."&reply_id=".$rowr['id']."\"><img src=\"quoteIcon.gif\"></a></td></tr>\n"; } echo "</td>\n"; echo "</tr>\n"; } echo "<tr><td colspan=\"2\" align=\"left\"><a href=\"./index.php?act=reply&id=".$row['id']."\">Reply Now</a></td></tr>\n"; echo "</table>\n"; } } }else { echo "Please view a valid topic!"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798814 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 Looks like a syntax error here's all the file error_reporting(E_ALL ^ E_NOTICE); //Report all error except NOTICES $id = mss($_GET['id']); $page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; $page = ceil($page); $limit = 10; $start = $limit; $end = $page*$limit-($limit); if($id){ $sql = "SELECT * FROM `forum_topics` WHERE `id`='".$id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This topic does not exists!"; }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(!$admin_user_level == 1) { echo "You cannot view this topic!"; } else { $a = (isa($row['uid'])) ? "<font style=\"color:#800000;font-weight:bold;\">ADMIN</font>" : ""; echo "<table border=\"0\" width=\"100%\"cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\"><b>".$row['title']."</b>- Posted on: <em>".$row['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($row['uid'],true)."<br>Post Count: ".post($row['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($row['message']); echo "</td>\n"; echo "</tr>\n"; $amount_check = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."'"; $amount_check_res = mysql_query($amount_check) or die(mysql_error()); $amount_count = mysql_num_rows($amount_check_res); $pages = ceil($amount_count/$limit); $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page-1)."\">« Prev</a>"; $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./index.php?act=topic&id=".$id."&page=".($page+1)."\">Next »</a>"; echo "<tr><td align=\"right\" colspan=\"2\" class=\"forum_header\">\n"; echo "Pages: "; echo $previous; for($i=1;$i<=$pages;$i++){ $href = ($page == $i) ? " ".$i." " : " <a href=\"./index.php?act=topic&id=".$id."&page=".$i."\">".$i."</a> "; echo $href; } echo $nextpage; echo "</td></tr>\n"; $select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; $select_res = mysql_query($select_sql) or die(mysql_error()); while($rowr = mysql_fetch_assoc($select_res)){ echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted on: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'],true)."<br>Post Count: ".post($rowr['uid'])."</br>".$a."</td>\n"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($rowr['message']); if($rowr['edit_time'] > 0){ echo "<tr><td align=\"left\" colspan=\"3\" class=\"forum_header\"><em>Edited at:".date("l jS \of F Y",$rowr['edit_time']) . " at " . date("h:i:s",$rowr['edit_time'])."</em></td></tr>\n"; } $adminz = isa($_SESSION['uid']); //if($adminz == 1){ // echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=topic&id=".$rowr['id']."\" onclick=\"return confirm('Are you sure you want to delete?')\"><img src=\"delete.gif\"></a></td></tr>\n"; //} if($adminz == 1 || $rowr['uid'] == $_SESSION['uid'] || $admin_user_level == 0){ echo "<tr><td align=\"right\" colspan=\"2\"><a href=\"index.php?act=mod&act2=reply&id=".$rowr['id']."\"><img src=\"edit.gif\"></a> <a href=\"index.php?act=test&id=".$rowr['tid']."&reply_id=".$rowr['id']."\"><img src=\"quoteIcon.gif\"></a></td></tr>\n"; } echo "</td>\n"; echo "</tr>\n"; } echo "<tr><td colspan=\"2\" align=\"left\"><a href=\"./index.php?act=reply&id=".$row['id']."\">Reply Now</a></td></tr>\n"; echo "</table>\n"; } } }else { echo "Please view a valid topic!"; } Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798836 Share on other sites More sharing options...
rEhSi_123 Posted April 1, 2009 Author Share Posted April 1, 2009 Cheers mate! The code you supplied works..... But there is one ISSUE which I am not able to figure out...... $a = (isa($row['uid'])) ? "<font style=\"color:#800000;font-weight:bold;\">ADMIN</font>" : ""; The above code displays ADMIN next to a username if the USER is a ADMIN......which is spot on! But, now say if a ADMIN starts a thread and if any non ADMIN user posts in the topic he automatically gets ADMIN displayed under his username :'( which I dont want......... and if a ADMIN comments in a topic which was started off by a normal USER the ADMIN letter is not present even though the user commented is a ADMIN........ Could you please shed some light....... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798848 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 sure thing sending PM Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-798855 Share on other sites More sharing options...
rEhSi_123 Posted April 1, 2009 Author Share Posted April 1, 2009 I have a feeling something is wrong in my create topic file...... Could somebody please check this for me. <?php if(!$_SESSION['uid']){ header("Location: index.php"); } $id = mss($_GET['id']); if($id){ $sql = "SELECT * FROM `forum_sub_cats` WHERE `id`='" .$id. "'"; $res = mysql_query($sql) or die(mysql_error); if(mysql_num_rows($res) == 0){ echo "The forum you are trying to create on, does not exists!\n"; }else { $row1 = mysql_fetch_assoc($res); if($row1['admin'] == 1 && $admin_user_level == 0){ echo "You are not a administrator, therefore you cannot post on this forum\n"; }else{ if(!$_POST['submit']){ echo "<table border=\"0\" cellspacing=\"3\" cellspacing=\"3\">\n"; echo "<form method=\"post\" action=\"./index.php?act=create&id=".$id."\">\n"; echo "<tr><td>Forum Sub Category</td><td><select name=\"cat\">\n"; $sql2 = "SELECT * FROM `forum_cats` WHERE `admin` < ".$admin_user_level."+1"; $res2 = mysql_query($sql2) or die(mysql_error()); while($row = mysql_fetch_assoc($res2)){ $sql3 = "SELECT * FROM `forum_sub_cats` WHERE `cid`='".$row['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); echo "<option value=\"0\">".$row['name']."</option>\n"; while($row2 = mysql_fetch_assoc($res3)){ $selected = ($row2['id'] == $id) ? " SELECTED" : ""; echo "<option value=\"".$row2['id']."\"".$selected."> ".$row2['name']."</option>\n"; } } echo "</select></td></tr>\n"; echo "<tr><td>Topic Title</td><td><input type=\"text\" name=\"title\"></td></tr>\n"; echo "<tr><td>Message</td><td><textarea name=\"message\" style=\"width:300px;height:100px;\"></textarea></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Create Topic\"></td></tr>\n"; echo "</form></table>\n"; }else{ $cat = mss($_POST['cat']); $title = mss($_POST['title']); $msg = mss($_POST['message']); if($cat && $title && $msg){ $sql = "SELECT admin FROM `forum_sub_cats` WHERE `id`='".$cat."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This forum sub category does not exist!\n"; }else { $row = mysql_fetch_assoc($res); if($row['admin'] == 1 && $admin_user_level !=1){ echo "You are not an admin therefore you cannot post a new topic on this forum!\n"; }else { if(strlen($title) < 3 || strlen($title) > 32){ echo "The Title must be between 3 and 32 characters\n"; }else { if(strlen($msg) < 3 || strlen($msg) > 10000){ echo "The message must be between 3 and 10000 characters\n"; }else { $date = date("d-m-y") ." at ". date("h-i-s"); $time = time(); $sql2 = "INSERT into `forum_topics` (`cid`,`title`,`uid`,`date`,`time`,`message`) VALUES('".$cat."','".$title."','".$_SESSION['uid']."','".$date."','".$time."','".$msg."')"; $res2 = mysql_query($sql2) or die(mysql_error()); $tid = mysql_insert_id(); topic_go($tid); } } } } }else { echo "Please supply all the fields\n"; } } } } }else { if(!$_POST['submit']){ echo "<table border=\"0\" cellspacing=\"3\" cellspacing=\"3\">\n"; echo "<form method=\"post\" action=\"./index.php?act=create\">\n"; echo "<tr><td>Forum Sub Category</td><td><select name=\"cat\">\n"; $sql2 = "SELECT * FROM `forum_cats` WHERE `admin` < ".$admin_user_level."+1"; $res2 = mysql_query($sql2) or die(mysql_error()); while($row = mysql_fetch_assoc($res2)){ $sql3 = "SELECT * FROM `forum_sub_cats` WHERE `cid`='".$row['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); echo "<option value=\"0\">".$row['name']."</option>\n"; while($row2 = mysql_fetch_assoc($res3)){ $selected = ($row2['id'] == $id) ? " SELECTED" : ""; echo "<option value=\"".$row2['id']."\"".$selected."> ".$row2['name']."</option>\n"; } } echo "</select></td></tr>\n"; echo "<tr><td>Topic Title</td><td><input type=\"text\" name=\"title\"></td></tr>\n"; echo "<tr><td>Message</td><td><textarea name=\"message\" style=\"width:300px;height:100px;\"></textarea></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Create Topic\"></td></tr>\n"; echo "</form></table>\n"; }else{ $cat = mss($_POST['cat']); $title = mss($_POST['title']); $msg = mss($_POST['message']); if($cat && $title && $msg){ $sql = "SELECT admin FROM `forum_sub_cats` WHERE `id`='".$cat."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "This forum sub category does not exist!\n"; }else { $row = mysql_fetch_assoc($res); if($row['admin'] == 1 && $admin_user_level !=1){ echo "You are not an admin therefore you cannot post a new topic on this forum!\n"; }else { if(strlen($title) < 3 || strlen($title) > 32){ echo "The Title must be between 3 and 32 characters\n"; }else { if(strlen($msg) < 3 || strlen($msg) > 10000){ echo "The message must be between 3 and 10000 characters\n"; }else { $date = date("d-m-y") ." at ". date("h-i-s"); $time = time(); $sql2 = "INSERT into `forum_topics` (`cid`,`title`,`uid`,`date`,`time`,`message`) VALUES('".$cat."','".$title."','".$_SESSION['uid']."','".$date."','".$time."','".$msg."')"; $res2 = mysql_query($sql2) or die(mysql_error()); $tid = mysql_insert_id(); header("Location: index.php?act=topic&id=".$tid.""); } } } } }else { echo "Please supply all the fields\n"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-799017 Share on other sites More sharing options...
rEhSi_123 Posted April 2, 2009 Author Share Posted April 2, 2009 Well problem resolved....... added this to my while loop: $b = (isa($rowr['uid'])) ? "<font style=\"color:#800000;\">ADMIN</font>" : ""; so the code is: while($rowr = mysql_fetch_assoc($select_res)){ $b = (isa($rowr['uid'])) ? "<font style=\"color:#800000;\">ADMIN</font>" : ""; echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted On: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'], true)."<br>Post Count: ".post($rowr['uid'])."<br>".$b."</td>"; echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo topic($rowr['message']); Thanks for all the support! Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-799111 Share on other sites More sharing options...
manny Posted April 2, 2009 Share Posted April 2, 2009 You are very welcome Quote Link to comment https://forums.phpfreaks.com/topic/151744-solved-forum-admin-and-user-issue-please-help/#findComment-799134 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.