dean7 Posted August 21, 2009 Share Posted August 21, 2009 Hi all on my website i have a mod panel witch only staff can see it (mod admin etc..) how could i code somthing so only the staff can see the link and access that page but users carnt? But if users try going to that url it move them to a different page? Thanks for you help Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/ Share on other sites More sharing options...
tecmeister Posted August 21, 2009 Share Posted August 21, 2009 Hi, Add a user level to the database for each person and make the default to 0. Then make staff's level equal to 1. Then put. <?php if($row['level'] == 1){ ?> <a href="cpanel.php">Cpanel</a> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903502 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 in my database i have user lvl in the users table witch has lvls like owner But when i change <?php if($row['level']== owner { ?> It doesnt show the link to the users who have the user lvl owner This is what im trying. <?php if($row['level'] == owner){ ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> but that dont show the link after Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903511 Share on other sites More sharing options...
tecmeister Posted August 21, 2009 Share Posted August 21, 2009 Could you paste me the full script of the page and I will have a look. Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903513 Share on other sites More sharing options...
Flames Posted August 21, 2009 Share Posted August 21, 2009 is the mysql field called level? also owner should be encased in ", i.e. "owner" Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903517 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 <div class="menutitle" onclick="SwitchMenu('sub1')">Staff Panel</div> <span class="submenu" id="sub1"> <?php if($row['level'] == "owner"){ ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> That is basicly the script. Its part of my menu. Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903522 Share on other sites More sharing options...
Daniel0 Posted August 21, 2009 Share Posted August 21, 2009 Try to place var_dump($row['level']); right before the if. What does that output? Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903524 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 My code is now <div class="menutitle" onclick="SwitchMenu('sub1')">Staff Panel</div> <span class="submenu" id="sub1"> <?php var_dump($row['level'] == "owner"){ // line 132 ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> But its now saying Parse error: syntax error, unexpected '{' in /home/a7502957/public_html/nav.php on line 132 Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903531 Share on other sites More sharing options...
Flames Posted August 21, 2009 Share Posted August 21, 2009 <div class="menutitle" onclick="SwitchMenu('sub1')">Staff Panel</div> <span class="submenu" id="sub1"> <?php var_dump($row['level']); if($row['level' == "owner"){ // line 132 ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> Try it like that Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903532 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 Doing that makes an error Parse error: syntax error, unexpected ')', expecting ']' in /home/a7502957/public_html/nav.php on line 133 My code <div class="menutitle" onclick="SwitchMenu('sub1')">Staff Panel</div> <span class="submenu" id="sub1"> <?php var_dump($row['level']); if($row['level' == "owner"){ // line 133 ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903536 Share on other sites More sharing options...
daveoffy Posted August 21, 2009 Share Posted August 21, 2009 this should work <?php var_dump($row['level']); if($row['level'] == "owner"){ ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903539 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 this should work <?php var_dump($row['level']); if($row['level'] == "owner"){ ?> - <a href="../admin/index.php" target="mainFrame">Admin</a><br> <?php } ?> That dont show admin panel bit but it says NULL Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903540 Share on other sites More sharing options...
daveoffy Posted August 21, 2009 Share Posted August 21, 2009 Do you have a connection to the database in that code? Do you have it connecting to the table level is in? Do you have a level named owner? Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903541 Share on other sites More sharing options...
dean7 Posted August 21, 2009 Author Share Posted August 21, 2009 Do you have a connection to the database in that code? Do you have it connecting to the table level is in? Do you have a level named owner? Yeah i have a connection to the database in the code I have the lvl called owner But what you mean by have it connecting to the table level is in? Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903544 Share on other sites More sharing options...
Daniel0 Posted August 21, 2009 Share Posted August 21, 2009 That dont show admin panel bit but it says NULL Right, that means that $row doesn't contain any value. You will need to replace $row with an array that contains the user info. Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903546 Share on other sites More sharing options...
daveoffy Posted August 21, 2009 Share Posted August 21, 2009 How is your database set up? -User -level -owner Table is User, row is level. Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903548 Share on other sites More sharing options...
jkewlo Posted August 21, 2009 Share Posted August 21, 2009 why dont u set the level into a session? what I do for my site.. and it works fine Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903549 Share on other sites More sharing options...
jkewlo Posted August 21, 2009 Share Posted August 21, 2009 I do it while the user submits his log in data so index.php - > check.php ( check.php sets all my sessions and checks the database for the proper username and password if username and password = true meaning it is correct then sends to profile.php which then if the sessions are correct for the user to have admin rights 3 being admin 2 being mod 1 being no admin/mod rights just regular member if it is 3 then it displays admin if it is 2 it displays mod if 3 it displays nothing. pretty simple way of doing it. if I was at home or had my scp connection i would give you my script for you to use. Link to comment https://forums.phpfreaks.com/topic/171324-user-levels/#findComment-903550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.