NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page [ PHP ] Track Refering Sites

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 03-28-2010, 03:37 PM THREAD STARTER               #1 (permalink)
CEO at Syack Inc.
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,879
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 




[ PHP ] Track Refering Sites


Below is a useful script that I wrote earlier today. Use it to track refering sites and insert them into the database when the user signs up. Basic PHP Knowledge Required



anypage.php
PHP Code:
<?php

if (isset($_SERVER['HTTP_REFERER'])) {     // check if there was a referrer

    
$uri parse_url($_SERVER['HTTP_REFERER']); 

    if(
$uri['host'] != "yourdomain.com"){          //Replace with your domain
        
$onvisit $_SERVER['HTTP_REFERER']; //example www.mail.com/iamatest.php?test=true
        
$onvisitshort $uri['host']; //example www.mail.com
????: NamePros.com http://www.namepros.com/code/647450-php-track-refering-sites.html

         
if (empty( $_COOKIE['refererlong'])){  // checks to see if cookie exists, if not sets one
             
setcookie ("refererlong"$onvisittime()+2592000"/");  //sets for 30 days
????: NamePros.com http://www.namepros.com/showthread.php?t=647450
             
setcookie ("referershort"$onvisitshorttime()+2592000"/");  // sets for 30 days
         

    }
}

?>
Insert the below code into your signup script to insert into a database.

signup.php
PHP Code:
<?php
$refererlong 
$_COOKIE['refererlong']; // calls long url referer cookie
$referershort $_COOKIE['referershort']; // calls short url referer cookie

//MySQL Insert Query Goes Here

?>
__________________
Poker News, articles, discussion
Syack - Shop.. Local

Two great events started with apples. The one that fell on Neuton's head and the one that Steve Jobs bite into.
Last edited by -Ray-; 03-28-2010 at 03:47 PM.
-Ray- is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:33 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger