08.09.2012, 13:40
Why you make double query? This should work->
PHP код:
$q = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'") or die (mysql_error()); // mySQL query
$r = mysql_num_rows($q); // Checks to see if anything is in the db.
if ($r == 1) { // There is something in the db. The username/password match up.
$_SESSION['logged'] = 1;
$row = mysql_fetch_array($q)
$_SESSION['admin'] = $row['admin'];
header("Location: site.php"); // Goes to main page.
exit(); // Stops the rest of the script.
} else { // Invalid username/password.
header("Location: login.php"); // Goes back to login page.
}