Is there a php function that will find the URL of where someone came to your site from?

For example, you have a site www.mysite.com. This link is on many other affiliate sites, say pricewatch.com. Now if someone is on pricewatch.com and clicks on my site link they will go to my index.php page. On this page I want to store the url they came from in a variable, and in the above example the value would be www.pricewatch.com.

Thanks

    The variable $_SERVER['HTTP_REFERER'] will return it..

    BUT BUT BUT BUT BUT BUT BUT BUT BUT BUT BUT BUT BUT

    It is not always set by the browser for privacy reasons ! So never rely on it !!!

      If known, the super-global $SERVER['HTTP_REFERER'] will have that value; but it is not required to be sent by the user agent and can otherwise be spoofed, so you cannot depend on it to be present or correct. For general, non-critical information purposes it's OK to use, but for more critical uses the only real solution is to have query string values in the referring links that you can grab via the $GET array to get the tracking information.

        Write a Reply...