I'm new to php so please don't punch me...
Here is a simple login page that I made and I don't understand why it doesn't work.
Code: Select all
$uname=$_POST['uname'];
$upass=$_POST['upass'];
$result=mysql_query("SELECT * FROM users where userName='".$uname."' and userPass='".$upass."'",$mysql_link);
if (!$result)
echo "ERROR: error occured in MySQL query.";
else //if the query was ok...
{
while ($row=mysql_fetch_array($result))
session_start();
$_SESSION['IDENT'] = $row['userID'];
echo $_SESSION['IDENT'];
}
When I trying to log in with the correct username&password it just don't write anything.
So I wanted to figure out where is my mistake.
First, I wanted to see that the query's answer is right.
I've wrote "echo $row['userID'];" and got the right answer. (15, like in the db.)
Than, I thought that mabe I have a problem in the php engine on my computer so I just wrote the following lines:
" $_SESSION['IDENT']=15;
echo $_SESSION['IDENT']; "
And again, I got the right answer.
So, why when I write :
$_SESSION['IDENT']=$row['userID'];
the session doesn't update to 15?!?!?!?!
I just don't get it...
thanx alot!