Jump to content

PHP 'or' operator


Boerboel649

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.