Boerboel649 Posted April 15, 2007 Share Posted April 15, 2007 This ought to be a simple question... I have a page which has the following PHP code: <?php if ($_SERVER['HTTP_REFERER'] != 'URLremoved') header("Location:/rostercpanel/login.php "); ?> Now, what I want to do, is add some other URL's, that are authorized URL's to come from. I've tried the 'or' and the '||' operators, but I have a feeling I'm doing it wrongly. Could someone please give me the code for this? If I didn't make myself clear enought let me know and I'll go into more detail. Thanks! Link to comment https://forums.phpfreaks.com/topic/47137-php-or-operator/ Share on other sites More sharing options...
ted_chou12 Posted April 15, 2007 Share Posted April 15, 2007 use && or AND, I believe that your logic is incorrect here, the statement must use be in false condition for all in order to process. Ted Link to comment https://forums.phpfreaks.com/topic/47137-php-or-operator/#findComment-229863 Share on other sites More sharing options...
Psycho Posted April 15, 2007 Share Posted April 15, 2007 I think your problem is that you are using a does not equal operator. If you have two or more negative conditions using OR then one of them will always fail (when testing the same property) Ex: if ($url != "url1" OR $url != "url2") That will ALWAYS fail because even if the value does equal one of the tests it won't equal the 2nd. You need to use the AND condition <?php if ($_SERVER['HTTP_REFERER'] != 'URL1' AND $_SERVER['HTTP_REFERER'] != 'URL2') header("Location:/rostercpanel/login.php "); ?> Link to comment https://forums.phpfreaks.com/topic/47137-php-or-operator/#findComment-229867 Share on other sites More sharing options...
Boerboel649 Posted April 15, 2007 Author Share Posted April 15, 2007 Ahhh... ok! Thanks so much!!! Link to comment https://forums.phpfreaks.com/topic/47137-php-or-operator/#findComment-229869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.