I have a login form where the member enters his
1. Pilot Callsign
2. Password
I want to declare that Pilot Callsign as the session variable on authentication.
Using that Pilot Callsign session variable, I will fetch data from the database relevant to his profile.
I already have the whole login page coded along with the restricted access pages (not coded by me).
Check this out
1. Page is coded like this and working PERFECTLY
---
Code: Select all
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['pilot_callsign'])) {
$loginUsername=$_POST['pilot_callsign'];
$password=$_POST['password'];
mysql_select_db($database_brn_system, $brn_system);
$LoginRS__query=sprintf("SELECT pilot_callsign, password, staff_level, firstname FROM pilots WHERE activated = 1 AND pilot_callsign=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $brn_system) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'staff_level');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
?>
2. As you can see, there already is a session variable declared for Pilot Callsign
But on the next page "Restricted Access Page", when I try to call this same Session Variable, it doesn't work.
I tried doing this
<?php echo $_SESSION['MM_Username'] ?>
Moreover, I even tried to fetch data from the table like this -
SELECT * FROM pilots WHERE pilot_callsign=$_SESSION['MM_Username']
Doesn't work :-\