Quick PHP Programming For $20

Discussion in 'Programming' started by bbardot, Jan 14, 2009.

  1. #1
    Hi,

    I'm doing some tracking with one of my websites. I'm currently passing URL variables to the next page
    by capturing it in a hidden field in a form.

    Eg <input name="var" type="hidden" value=<? echo $_GET['var'] ?>>

    So if the user enters using for instance http://www.mysite.com/?var=value
    "value" will be captured and passed on to the next page where getQueryStringVariable('var') will capture and store it.

    However, there are some people directly entering the site and from other sites be it google, yahoo etc. which are not captured because there's nothing in the variable.

    What I need is to find out what the referring site is and pass it to the variable above.
     
    bbardot, Jan 14, 2009 IP
  2. vinayendra

    vinayendra Active Member

    Messages:
    262
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hi there we will compete your work.



    PM for more details.
     
    vinayendra, Jan 14, 2009 IP
  3. vinayendra

    vinayendra Active Member

    Messages:
    262
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    you can do by this

    if some from google the var value == empty

    if ($_REQUEST['var'] == "")
    {
    $ref = $_SERVER['HTTP_REFERER'];
    
    if ($ref=="")
    {
    $ref = "externalsite";
    }
    header('Location: http://www. example. com/?var=$ref');
    
    }
    
    PHP:
    put this code at your sites home page! so i will trace its referal if referal == empty then it will asign var val = from esternal site and lands on page with

    http://www. yoursite .com/var=externalsite

    I hope this will help you!
     
    vinayendra, Jan 14, 2009 IP
    grungemedia likes this.