Okay I have a session starting, and a query to verify a user against a database. This returns the user_id and the user_type
The type reffers to access rights and the user to the individual user. Sounds easy enough.
I register the variables in the session after running the query and then pop the new values in. Echoing them back immediately works and I get the correct output. But later on I have a test if(!$user_logged_in)
$user_logged_in is the user_id of the user that just logged in.
Any ideas as to why it seems to think that $user_logged_in does not exist when i can get an echo of it higher up?
Here's my code
session.php4
<?
session_start();
if ($tryLogin==true&&$username&&$password)
{
$strSQL = "select worker_id, access_id from bill_worker where user = '$username' AND pass = '$password' AND include = 1";
if($debug==1){echo"worker test sql: $strSQL";}
$result=mysql_query($strSQL);
$myrow=mysql_fetch_array($result);
if (mysql_numrows($result) != 0)
{
session_register("user_logged_in");
session_register("user_type");
$user_type = $myrow["access_id"];
$user_logged_in = $myrow["worker_id"];
$success ="TRUE";
if($debug==1){echo"<br>user_logged_in=$user_logged_in<br>user_type=$user_type<br>Success=$success";}
}
and here is the part that will not work
<?
if (!$user_logged_in) {
include("inc/loginform.php4");}
else {
include("inc/usernav.php4");}
?>
the damn thing keeps outputting the login form and not the menu! Help me if you can.
thanks Mike