Help with IF ELSE
| From: | David Stoltz | Date: | Thu, 04 Dec 2008 19:49:12 +0000 |
| Subject: | Help with IF ELSE | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-284111@lists.php.net to get a copy of this message | ||
Hi All,
I'm new to PHP - I'm trying to figure out what is wrong with a simple IF
ELSE block I have...if the recordset $rs is empty (login fails), the 1st
part of the block works, and redirects the user to default.php - but if
the login works, and $rs is not empty, the 2nd "else" part does not
work, and does not redirect to menu.php - I just get a blank white
screen on the login.php page (where this code is)....
Any ideas? What is the proper way to detect an empty recordset?
Thanks!
Below is the code:
--------------------
...
$query = "SELECT user_id FROM users WHERE username = '$uname' AND
password = '$pword'";
$rs = $conn->execute($query);
if($rs->EOF)
{
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
header("Location: default.php?err=Invalid%20Login%20Attempt");
exit;
}
else
{
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
header("Location: menu.php");
exit;
}