Referrer based script - quick help needed

Discussion in 'PHP' started by vetting, Dec 27, 2007.

  1. #1
    I need to build some referrer checking into a existing php page that I have. What I need it to do is the following:

    - Look at the referrer if there is one

    The referrer if there is one will be
    http://cgi.ebay.com/Test-Auction-Do...oryZ1337QQssPageNameZWDVWQQrdZ1QQcmdZViewItem

    http://cgi.ebay.co.uk/Mens-Sunglass...yZ131411QQssPageNameZWDVWQQrdZ1QQcmdZViewItem

    http://cgi.ebay.ca/XBox-360-Halo-3-...tcZphotoQQssPageNameZWDVWQQrdZ1QQcmdZViewItem

    What I need to do is be able to strip out the
    ebay.ca or ebay.co.uk or ebay.com and set another variable based upon which one it is.

    Thank you for your help.
     
    vetting, Dec 27, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can try something like this:

    
    $domain = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
    
    PHP:
    Then just create a switch or if/else statements to execute what you want for each variant of $domain.

    Hope this helps :)
     
    tonybogs, Dec 27, 2007 IP