18.05.2010, 18:41
1. You cannot use the $row variable outside your loop 
2. Why use a loop? If it is only a username, there should only be 1 match, so you can just use
I don't know what mysql_fetch_assoc does, but I am going to check that now because I have a test the day after tomorrow
(mysql_fetch_assoc looks like mysql_fetch_array.. oh well.)
As for the rest, it looks all OK to me.
I did it like this:
Code is only for educational purposes only. It should not be considered as working, even though it most probably will. 
-Edit: Ah, so that is mysql_fetch_assoc(); Just looked it up

2. Why use a loop? If it is only a username, there should only be 1 match, so you can just use
Код:
$row = mysql_fetch_array($query);

As for the rest, it looks all OK to me.
I did it like this:
Код:
$query = mysql_query("SELECT * FROM users WHERE username='$_POST[username]'"); if(mysql_num_rows($query) == 0) { // no results die('Username not found'); } else { $fetch = mysql_fetch_array($query); if(md5($_POST['password'] === $fetch['password'])) { // a result and log the user in by means of a session $_SESSION['username'] == $_POST['username']; } else { die('Wrong password'); } }

-Edit: Ah, so that is mysql_fetch_assoc(); Just looked it up
