Forum Moderators: coopster
if(strpos($_POST['filter_zip'], ",") == false) && (is_numeric($_POST['filter_zip']) == false) {
header("Location: error.php?code=135&term=".$_POST['filter_zip']);
}
As you can see, I want it to run only if the supplied POST does not contain a comma and is not numeric. I submit, via a form, the letters "nix", which fit this description, but this IF statement fails to run. Is the reason too obvious for me to see it?
Thanks for any help!
[code]
if(strpos($_POST['filter_zip'], ",") === false) {
echo "NO COMMA";
if(is_numeric($_POST['filter_zip']) == false) {
echo "NO NUMBERS";
header("Location: error.php?code=135&term=".$_POST['filter_zip']);
echo "SKIPPED TRANSFER";
}}
{/code]
And I get all of my echos printed out, but the HEADER command doesn't run. What gives?
EDIT: But it does work if I place just this statement in a file of its own. Guess I'd better comb through my script.
EDIT 2: Still stuck. The crazy thing is that, when this header skips, it only causes another error further in the script, triggering another header command that actually DOES work. I'm so lost.
Turns out I needed to place an EXIT statement at the end of my condition. Without it, the script continued to execute and reached a new header command before the previous one could complete.
In case anyone else has the same issue, here's my new code:
if(strpos($_POST['filter_zip'], ",") == false) && (is_numeric($_POST['filter_zip']) == false) {
header("Location: error.php?code=135&term=".$_POST['filter_zip']);
exit;
}