Help with IF ELSE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux