![]() |
|
Admin Check Script - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Website Scripting & Security (https://lckb.dev/forum/forumdisplay.php?fid=197) +---- Forum: Website Releases (https://lckb.dev/forum/forumdisplay.php?fid=135) +----- Forum: Ep1 Websites (https://lckb.dev/forum/forumdisplay.php?fid=185) +----- Thread: Admin Check Script (/showthread.php?tid=1005) |
- Blackfire - 08-11-2012 Version 1 - Admin only page <? //currently an example, change to your desired infomation $dbuser = "root"; $dbpass = ""; $dbhost = "localhost"; $dbname = "newproject_db"; //connect to database $msconn = mysql_connect($dbhost, $dbuser, $dbpass); $db = mysql_select_db($dbname, $msconn); $admin = ''; //Put here the session id that your site uses to save user info. // Check Admin Levels On Database $checkadmin = mysql_query("SELECT * FROM t_characters WHERE a_user_index = '$admin' AND a_admin > 0"); if(mysql_num_rows($checkadmin) > 0) { } else { echo "<font color='#FF0000'>You Do Not Have Access To This Page</font>"; die(); } ?> Version 2 - Information only admin's can see (Credits to MaX) <? //currently an example, change to your desired infomation $dbuser = "root"; $dbpass = ""; $dbhost = "localhost"; $dbname = "newproject_db"; //connect to database $msconn = mysql_connect($dbhost, $dbuser, $dbpass); $db = mysql_select_db($dbname, $msconn); $admin = ''; //Put here the session id that your site uses to save user info. $admin_check = mysql_query("SELECT * FROM t_characters WHERE a_account_index = '$admin'"); while($admin_check1 = mysql_fetch_array( $admin_check )) { //Administrators if($admin_check1['a_admin'] == "10") //Change this to what level admin's can see this page. { //Info only admin's can see goes here. } } ?> |