AndieB Posted January 9, 2009 Share Posted January 9, 2009 Hi all, I'm writing a script which will analyse the POST from a URL. It will check for the $_GET variable. Now, there are two strings or what you can call them that MUST both contain a value each in order to proceed with the script. The URL looks like this: activate.php?e=value?cc=value Now, I started to type the IF statement, but got confused in my mind on HOW I should write it. Which of my two examples below, actually do what I request... BOTH "strings" should each contain a value. if (!isset($_GET["e"]) AND !isset($_GET["cc"])) { send to an error page } else { proceed... } OR this one: if (!isset($_GET["e"]) OR !isset($_GET["cc"])) { send to an error page } else { procced... } Anyone who can clear up my confused mind? Thank you in advance for any kind of help! Sincerely, Andreas Link to comment https://forums.phpfreaks.com/topic/140209-solved-the-results-of-if-statement-with-and-or-or/ Share on other sites More sharing options...
elflacodepr Posted January 9, 2009 Share Posted January 9, 2009 Basically you will use this one: if (!isset($_GET["e"]) AND !isset($_GET["cc"])) { send to an error page } else { proceed... } as you want "BOTH" variables to contain a value. If you use this: if (!isset($_GET["e"]) OR !isset($_GET["cc"])) { send to an error page } else { procced... } You will tell PHP that at least one variable can be left without value, which is not what you want. Same if you tell someone to pick between "red OR blue"...you have to select only one. Link to comment https://forums.phpfreaks.com/topic/140209-solved-the-results-of-if-statement-with-and-or-or/#findComment-733675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.