[thelist] PHP header wierdness
Tom Dell'Aringa
pixelmech at yahoo.com
Tue Jan 21 12:00:08 CST 2003
I'm checking against a password, and I want to send them back to the
login page if they enter it wrong. If the row returns 0 records, I
have a header sending them back with a message, otherwise I send them
on to the page with another header. Here is my code:
-----------------
//$result is my query
if(mysql_num_rows($result) == 0)
{
$message = "We're sorry, either the user name or password you
entered was incorrect. Please try again.";
header ("Location: login.php?msg=" . $message);
}
// Get db results
$row = mysql_fetch_array($result);
$aid = $row["aid"];
setcookie("aid", $aid, "", "/");
header ("Location: page.php");
--------------------------------------------------
The problem is, when I entered wrong info - even though
mysql_num_rows($result) returned 0 as it should, the script still ran
the LAST header, sending them to page.php instead. This is very odd,
how can it jump out of an if loop with a header?
Anyway, I added die(); after my first header and now it works..why?
That seems very odd.
Tom
=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the thelist
mailing list