I have this php script it's not inside a function
$num = mysql_num_rows($result);
if ($num == 0)
{
header("Location:index.php#captcha");//Location:#errorlogin.html");
$_POST[password]="";
exit;
}
It always seems to continue executing everything after this part regardless of $num being equal to 0 I have already tried exit("message"), die, return etc. Sorry if it's a noobish question haha
You're redirecting the page.
An example to notice from this page:
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
$_POST[password]="";
That should probably be (note the '
):
$_POST['password'] = "";
The function exit()
definitely stops execution when it is executed. There must be something wrong with your if condition.
In PHP multiple values "equal" to zero (if you use ==
). Try var_dump($num)
to see what's really in there.
exit
would not working because it is has 2 dependency
A. if ($num == 0)
if $num
is not zero exit would not work
B. header("Location:index.php#captcha");
If your location works exit would not wort
try
$num = mysql_num_rows ( $result );
if ($num == 0) {
$_POST ['password'] = null;
header ( "Location: http://yoursite.com/index.php#captcha" ); // Location:#errorlogin.html");
exit();
}
else
{
echo "Found $num in the database";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.