Jump to content
Old threads will finally start getting archived Γ—
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 Γ—

allow users


Merlin πŸ€–

Recommended Posts

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?!

Link to comment
https://forums.phpfreaks.com/topic/66835-allow-users/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335048
Share on other sites

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;
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335052
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/66835-allow-users/#findComment-335370
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.