First(this is on a side note), look into the mysql_fetch_object() function. It will allow you to reference your results by column name instead of using an index.
Example:
$row->column_name
instead of
$row[0]
Just easier to keep track of things esp. when you are returning many fields.
OK, your real problem. You say you call the following script on every page.
<?
session_start("$admin_username");
session_register("admin_number", "admin_name", "admin_username", "admin_password", "admin_email", "admin_lastlogin");
?>
First, session_start() does not take any arguments. It just creates an new session or resumes a current one. In other words, it allows you to use session variables on that page.
Second, when you call the session_register() function, you are setting session variables. If you call session_register every page, those variables are being reset every page and unless every page has each variable present("admin_number", "admin_name", etc) you are essentially setting those variables equal to nothing.
Here is something else to think about. You might have register_globals disabled. If you are running php 4.2 or later, this is the default. Check out your php.ini file or use the phpinfo() function to verify this. If that is the case, you should change your script not your php configuration. It will make your app more portable and more secure. You cannot use session_register() to register session variables when register_globals is off.
I recommend something similiar to this to set and check session variables for authentication purposes.
if you use the beatass mysql_fetch_row() function:
$_SESSION['admin_number'] = $row[0];
set the rest of your variables the same way
or if you use the badass mysql_fetch_object() function:
$_SESSION['admin_number'] = $row->admin_number;
set the rest of your variables the same way
Check to see if the user has been validated by putting this at the top of every script you want to check:
if(!isset($_SESSION['admin_number']))
{
redirect user to unauthorized page or just print message saying unauthorized access
exit;
}
else
{
show them the real page
}
If you have register globals turned on, you should consider turning it off.
Hope this helps.
Say what up to dre and big boy if you're near ATL.