If refferer=example.com echo=this else echo=that Please help on how to do that!

Discussion in 'PHP' started by rudeturk, Apr 16, 2008.

  1. #1
    Hi,
    i need a php code to check my refferer and if the refferer is an website which i have chosen it echos one thing else it echos the other thing.
    can you help?
    for example if $refferer="google.com"
    urgent
     
    rudeturk, Apr 16, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    CreativeClans, Apr 17, 2008 IP
  3. rudeturk

    rudeturk Well-Known Member

    Messages:
    884
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Thanks alot for the reply, but can anyone give an example for my function please like a full working example?
     
    rudeturk, Apr 17, 2008 IP
  4. salsan

    salsan Active Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #4
    if(GetDomain($_SERVER['HTTP_REFERER'])=='google.com')
    {
        echo 'you are from google.com';
    }
    
    
    function GetDomain($url)
    {
    $nowww = ereg_replace('www\.','',$url);
    $domain = parse_url($nowww);
    if(!empty($domain["host"]))
    	{
    	 return $domain["host"];
    	 } else
    	 {
    	 return $domain["path"];
    	 }
    
    }
    PHP:
     
    salsan, Jul 18, 2010 IP