Capture Referrer Name and format it too!

Here is the php that will get the name of the domain who your visitor is referred from¬† $_SERVER[‘HTTP_REFERER’]; but itwill display the full address path http://therefferingsite.com

Here is how you can format it to be www.thereferringsite.com and if you are using it from one of your own sites you can ever get cute and do a rewrite in the .htaccess file to format the domain the way you want and then display it.¬† I did this for another of my websites to insert the referring domain without the www (since I used the htaccess rewrite!) and use the same text for the rest of the page it worked great…

anyway here is the code

<? $referringurl = $_SERVER[‘HTTP_REFERER’];
$urlvariable = “$referringurl”;
$ref = parse_url($urlvariable);?>

here is how I displayed is

<a href=”<? echo ‘<span style=”text-transform:capitalize;”>’. $ref[‘host’] . ‘</span>’ . ‘/contact.php’ ?>

Wow this excites me I must be a Huge Dork!

Obligatory Will Rogers quotes

Half our life is spent trying to find something to do with the time we have rushed through life trying to save.

There are 3 kinds of people the one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves.

The road to success is dotted with many tempting parking spaces.