Page 1 of 1

yet again another problom with SESSIONS

Posted: Thu Jan 22, 2004 2:41 pm
by dull1554
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

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.
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)

Posted: Thu Jan 22, 2004 2:44 pm
by markl999
You never select age and type from the db...
SELECT password FROM <----

The 'e' is coming from the word 'error' ;)

Posted: Thu Jan 22, 2004 2:51 pm
by dull1554
ahh i hate being stupid sometimes

thanks