Crew-Portal Posted August 27, 2007 Share Posted August 27, 2007 Hi at the bottom of my site I would like to put an admins access page. the administrators use login id's instead of usernames (They also use usernames but they login with a number for the panel!) Thier Id's are 000, 001, and 002! The session_register variable for when someone logs in is set to $valid_user basically what I am trying to do is this but it is not allowing me! <?php if ($valid_user = array('000','001','002'){ ?> <table width="900" border="0"> <tr> <td>asdfasdf</td> </tr> </table> <p> </p> <?php } ?> so this is for if the login is set to 000 or 001 or 002 it displays a table and that table will soon have links to admin stuff! But my code is not workig! Can someone help me?! Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/ Share on other sites More sharing options...
evillair Posted August 27, 2007 Share Posted August 27, 2007 Have you tried == instead of = ? ($valid_user == array('000','001','002') Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335036 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 oops! Big mistake! Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335038 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 No I tried if ($valid_user == array('000','001','002')){ on the first line updating the original and it jjust doesnt dispaly anything anymore! so thats not the prob (well its one piece of the problem but still doesnt make the thing work) Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335039 Share on other sites More sharing options...
evillair Posted August 27, 2007 Share Posted August 27, 2007 You could try: $valid_user_id = array('000','001','002'); if ($valid_user == $valid_user_id) {...} Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335040 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 dont work! Arghh honestly this shouldnt be hard! Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335042 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 lets just forget the array and try to think of another solution! I have tried or and that doesnt work?! Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335044 Share on other sites More sharing options...
evillair Posted August 27, 2007 Share Posted August 27, 2007 It may be in the way you are using the $valid_user? I use $_SESSION's for things like this... $sql = mysql_query("SELECT * FROM table_name"); $userinfo = mysql_fetch_array($sql); $_SESSION['user_id'] = $userinfo['user_id']; $test = '001'; // if this works then use an array if ($_SESSION['user_id'] == $test) {...} echo out $valid_user and see shows up too. Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335048 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 no my users can log in and post information to mysql and only allow certain pages if thier $valid_user != NULL each time they post to mysql it also posts thier $valid_user like jimmy or joe! it does get carried over! just so that you know for login I use: <?php if ($action == 'login'){ $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql="SELECT * FROM $tbl_user WHERE username = \"$_POST[username]\" AND password = \"$_POST[password]\""; $result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); $num=mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $active = $row['active']; $confirm = $row['confirm']; } if($active == "yes") { $valid_user = $_POST['username']; $valid_password = $_POST['password']; session_register("valid_user"); session_register("valid_password"); $error = $tblstart . 'Login Successful' . $tblend; } if($active == "no") { $error = $tblstart . 'You have Been Banned From ' . $site_shrt . ' For Abuse On Our Forums!' . $tblend; } elseif($passpw == NULL) { $error = $tblstart . 'You Did Not Enter A Password' . $tblend; } elseif($userac == NULL) { $error = $tblstart . 'You Did Not Enter A Username' . $tblend; } elseif($valid_user == NULL) { $error = $tblstart . 'You Entered Incorrect Login Information' . $tblend; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335052 Share on other sites More sharing options...
uwannadonkey Posted August 27, 2007 Share Posted August 27, 2007 you use sessions right? go through the sessions, make it so that $_SESSION['username'] is chosen and then check if $_SESSION['username'] == to the admin ID's and if it is, echo the links, if it isnt, echo nothing Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335074 Share on other sites More sharing options...
Crew-Portal Posted August 27, 2007 Author Share Posted August 27, 2007 Yes that is what I have. But I have 3 admin accounts so how do I get it so that if it is one of the 3 it echos the links? Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335081 Share on other sites More sharing options...
uwannadonkey Posted August 27, 2007 Share Posted August 27, 2007 like i said, since i dont know your exact values, do this: check the user id, if its 001,002,003, and so on, just do this: if userid is less than your max admin id #(since the rest are all lettered, right?) echo " links, blah blah"; or just do what i do: in my game, each player gets a permission level, each with diff meaning, new user, gets 0, meaning hes a player, -127 means hes banned, 127 means game owner, 126 game admin, etc etc. if u choose to do the way i did, then you should consider: if $user->permission_level == 127 or so, then you echo Quote Link to comment https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335370 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.