Jump to content

allow users


Crew-Portal

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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.