Jump to content

if statement not working correctly


cloudll

Recommended Posts

I am using the following request on my site (index.php)

 

$compass = $_REQUEST['compass'];

 

I wanted to use an if statement to echo an error message if $compass was anything other than north,east,south or west. However the code im using is constantly displaying the error message even when /index.php?compass=north etc. Can anyone see what I have done wrong?

 

    if (($compass != "north") || ($compass != "east") || ($compass != "south") || ($compass != "west")) {

    echo '<strong>Stop cheating!</strong>';

}

Link to comment
https://forums.phpfreaks.com/topic/258412-if-statement-not-working-correctly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.