yet again another problom with SESSIONS
Posted: Thu Jan 22, 2004 2:41 pm
ok in my database i have a field called "type", this field contains either "user" or "admin", when i query the database all that is returned is the letter "e".
heres my code
login.php
does anyone know why it returns "e" nomatter what, and maybe a possiable soultion, i like sessions but i've been having lots of problems,
and by the way i don't get any errors and even when im not loged in, if i echo the session "type" it still returns "e" (this is after the session is destroyed)
heres my code
login.php
Code: Select all
<?php
include "inc.php";
$username = stripslashes($_POST['user']);
$password = stripslashes($_POST['password']);
$query = mysql_query("SELECT password FROM users WHERE username='$username'");
$db = mysql_fetch_array($query);
$db_pass = $db['password'];
$userage = $db['age'];
$usertype = $db['type'];
if (md5($password) == $db_pass)
{
$_SESSION['user'] = $username;
$_SESSION['age'] = $userage;
$_SESSION['type'] = $usertype;
echo $_SESSION['type'];
}
else
{
echo "not found in database! please register!";
}
?>
//all that is contained in inc.php is the db connection.and by the way i don't get any errors and even when im not loged in, if i echo the session "type" it still returns "e" (this is after the session is destroyed)