How can I do this?

Discussion in 'Programming' started by Yuuko008, Oct 12, 2009.

  1. #1
    I'm posting it here because I really don't know what script can make this possible.

    Is there anyway that i can give condition based on what site the visitor came.

    For example,
    If (the visitor came from www.yuukoweb.com)
    {
        show this
    }
    else
    {
        show this
    }
    PHP:
    Is this possible? And can you tell how?
     
    Yuuko008, Oct 12, 2009 IP
  2. ModusOperandi

    ModusOperandi Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi, you want to look at getting the referer of the website

    So something like this (I do C# not PHP so this mat not be 100% accurate but will give you an idea)

    
    
    if(isset($_SERVER['HTTP_REFERER']) =="www.mywebsite.com")
    {    
    
    // Show this
    
    }
    else
    {
     // show this
    
    }
    
    
    Code (markup):
     
    ModusOperandi, Oct 13, 2009 IP
  3. wrdesign

    wrdesign Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can use $_SERVER['HTTP_REFERER'] to get http address referer, and make condition for it.
     
    wrdesign, Oct 13, 2009 IP
  4. sunchiqua

    sunchiqua Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if ($_SERVER['HTTP_REFERER'] == "http://www.domain.com/") {
        echo "You came from domain.com! Accepted.";
    } else {
        echo "Sorry, page content visible only for those who came from domain.com!";
        exit();
    }
    PHP:
     
    sunchiqua, Oct 13, 2009 IP
  5. Yuuko008

    Yuuko008 Member

    Messages:
    682
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    33
    #5
    Thanks. Now another question. How can i try to prevent direct traffic from a specific page in my site.

    Example.

    if (you type in your browser directly www.mydomain.com)
    {
       you will be redirected to a certain page
    }
    else
    {
       you can enter
    }
    Code (markup):
    Is this possible?
     
    Yuuko008, Oct 13, 2009 IP