PHP if statements - validating more than 2?

mac-philiac

New member
How do I add a second thing to check in a PHP statement?

For example:

if ($_POST['password'] != 123456789) {
echo "That is an incorrect password.";
}

I want it to validate another password (I need more than 1 password) like:

if ($_POST['password'] != "123456789"."987654321") {
echo "That is an incorrect password.";
}

The above doesn't work. How would I accomplish the validation of the field with 2 or more possible "passwords"?

Thanks!
 
Use the following code:

if ($_POST['password'] != "123456789" && $_POST['password'] != "987654321") {
echo "That is an incorrect password.";
}


according to the given code, the script would compare the entered password with 123456789 and 987654321. If the password does match it will show the message. If the password matches with either of the given two, the message will not be shown
 
As with Busted if you want "OR" you use "||" as your operator,


if ($_POST['password'] != "123456789" || $_POST['password'] != "987654321") {
echo "That is an incorrect password.";
}

if you are validating on both his code is correct.
 
Back
Top