RE: [PHP] registering a session variable from a select * query.
| From: | Phillip S. Baker | Date: | Wed, 06 Mar 2002 20:06:01 +0000 |
| Subject: | RE: [PHP] registering a session variable from a select * query. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87510@lists.php.net to get a copy of this message | ||
A few things here.
Is this the full code you are using?
First thing however is that you have to specifically assign values for a session variable.
It is simply not enough to register the session variable.
So if you
session_register("login_username");And echo $login_username it will print nothing. But if you
session_register("login_username");Then say $login_username = $username echo $login_username That will print the username. Secondly and I do not know if you are just not showing me all the code.
else { $admin_level_var=mysql_query($mysql_authorisation); ?>I do not see you declaring the $mysql_autorisation anywhere. Thirdly if there is a successful login process I would ptu something like.
else {
session_register('user_auth_level');
$sql = "SELECT auth_level FROM accounts WHERE username=$username and password=$password
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$user_auth_level = $row[0];
}
This all make sense to you?
Phillip
At 11:28 AM 3/6/2002 Wednesday, you wrote:
Hi Phil thanks for taking the time to reply back. allow me to share my code (still learning so be gentle.) I register 2 session vars from 2 input boxes. I then select * from the user table where the to variables match (username and password) if they match I want to register the auth_level field for that user as a session var - if they don't match I unregister the session vars and put a failed screen up. I have "almost" got there, to test it I print the $user_auth_level variable, so far it is coming up blank. Hope you can help.