Well it's not working. I thought it was a few days ago but now it's not working for some reason.
Here's the exact code. When I echo out the $_SESSION variables on another page nothing is there.
Code: Select all
//creat sql statement
$sql="SELECT * FROM $tbl_name WHERE uName='$uName' and pWord='$encryptedPass'";
$result=mysql_query($sql);
//count matching row. If match then $count = 1
$count=mysql_num_rows($result);
if($count==1){
$row = mysql_fetch_row($result);
$email = $row['email'];
$privLevel = $row['privLevel'];
session_start();
$_SESSION['validName'] = 'valid';
$_SESSION['validPass'] = 'valid';
$_SESSION['userName'] = $uName;
$_SESSION['email'] = $email;
$_SESSION['privLevel'] = $privLevel;
require_once '../db/dbclose.php';
header("location: ../../app/home.php");
}
else{
echo "Wrong Username or Password";
}
validName, validPass, and userName work but they aren't coming from the database.
email and privLevel are not getting retrieved from $row['email'] and $row['privLevel']
Can anyone see something I'm overlooking in my code?
Thanks
I added $_SESSION['row'] = $row; and then print_r($_SESSION); in the home page and this is what I get
Array ( [validName] => valid [validPass] => valid [userName] => isimmons [email] => [privLevel] => [row] => Array ( [0] =>
noone@nowhere.com [1] => 0 ) )
So it is putting it into $row but not getting the data from $row[] array into individual variables
Thanks