dean7 Posted February 18, 2010 Share Posted February 18, 2010 Hi all, on my website i have a Owner Panel which your userlevel needs to be 4 other wise you carnt veiw it... <?php session_start(); include ("includes/config.php"); include ("includes/functions.php"); $when = gmdate('Y-m-d h:i:s'); // Date the log happend. $get = mysql_query("SELECT userlevel FROM users WHERE username = '$username'"); $got = mysql_fetch_object($get); $userlevel=$get->userlevel; // main varibales $username = $_SESSION['username']; // Gets the $username if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){ header("Location: index.php"); }else{ $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE username='".$_SESSION['username']."'")); } // Checking login status, if not logged in got to the header location. (index.php); if ($userlevel == "4"){ // Do this.. echo ("Welcome $username, Your level is <font color=darkred>Owner</font>"); } elseif ($userlevel < "4"){ // Do this... echo ("<b><font size=3>Get Away! - Action Logged!"); // echo message saying "Not meant to be here" $action = "Tryed Getting On Owner Panel"; // What the user tryed doing when should'nt be there. $addlog = mysql_query("INSERT INTO adminlogs WHERE username = '$username', action = '$action', date = $when"); // Insert to database } ?> <html> <head> <title>Owner Panel</title> <?php include ("style.css"); ?> </head> <body> <br /> <align="center"><table width="90%" height="" cellpadding="0" cellspacing="0" border="1" bordercolor="#000000"> <tr> <td class="header"> <align="center">Owner Cp</align> </td> </tr> <tr> <td class="forum"> <align="center">Please Note: All Actions Are Logged!</align> </td> </tr> <tr> <td class="forum" width="45%"> <strong>User Settings</strong> </td> <td class="forum" width="45%"> <strong>Game Settings</strong> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/owner/edit_profile.php">Edit User Profile</a> </td> <td class="tablestyle"> ~ <a href="../pannels/staff/ban.php">Ban User</a> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/owner/user_stats.php">User Stats</a> </td> <td class="tablestyle"> ~ <a href="../pannels/topstaff/ip_ban.php">Ip Ban</a> </td> </tr> <tr> <td class="forum" width="45%"> <strong>Log's</strong> </td> <td class="forum" width="45%"> <strong>Help Systems</strong> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/topstaff/userlogs.php">User Logs</a> </td> <td class="tablestyle"> ~ <a href="../pannels/staff/get_ticket.php">Help Desk Ticket</a> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/topstaff/modlogs.php">Mod Logs</a> </td> <td class="tablestyle"> ~ <a href="../pannels/staff/abuse_panel.php">Abuse Ticket</a> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/owner/headmodlogs.php">Head Mod Logs</a> </td> <td class="tablestyle"> ~ <a href="../pannels/topstaff/answered_tickets.php">Answered Tickets</a> </td> </tr> <tr> <td class="tablestyle"> ~ <a href="../pannels/owner/admin_logs.php">Admin Logs</a> </td> <td class="tablestyle"> ~ <a href="#">Nothing Here<a/> </td> </tr> </table></align> </body> </html> Ive coded that piece of code but even if the user has a userlevel of 4 it still dont let them veiw the page. :S anyway know why? Thanks. Link to comment https://forums.phpfreaks.com/topic/192508-userlevel-login/ Share on other sites More sharing options...
teamatomic Posted February 18, 2010 Share Posted February 18, 2010 So what does $userlevel give you when you echo it out. Also, dont use the quotes around the userlevel in the if statement, its an integer not a string, bad practice. if ($userlevel == 4) HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192508-userlevel-login/#findComment-1014295 Share on other sites More sharing options...
dean7 Posted February 18, 2010 Author Share Posted February 18, 2010 When i tryed echoing $userlevel it dont show nothing. Is there any other way i could make it so only the user's with that userlevel can get onto that page? Link to comment https://forums.phpfreaks.com/topic/192508-userlevel-login/#findComment-1014335 Share on other sites More sharing options...
jl5501 Posted February 18, 2010 Share Posted February 18, 2010 this line is wrong $userlevel=$get->userlevel; should be $userlevel=$got->userlevel; Link to comment https://forums.phpfreaks.com/topic/192508-userlevel-login/#findComment-1014341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.