OK,
Create a mysql database and table like :
CREATE TABLE IF NOT EXISTS `visits` (
`id` int(100) NOT NULL auto_increment,
`ref` varchar(1000) character set utf8 collate utf8_unicode_ci NOT NULL,
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ipaddress` varchar(100) NOT NULL default '0.0.0.0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Then use the code:
PHP Code:
<?php
# Gets the reffering site , Inserts into the private database for later graphing and documatiation.
$ipaddress = $_SERVER['REMOTE_ADDR']; // Get the users IP ( so i can get their country code etc ) $refsite = getenv("HTTP_REFERER"); //( Get the referring URL ) if ($refsite == "") { $refsite = "Unknown / Direct Visit"; // If they visited directly }
$con = mysql_connect("localhost","databasename","password"); // Maybe uname :root password blank"" if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("YOURDATABASENAME", $con);
$refsite = mysql_real_escape_string($refsite);
mysql_query("INSERT INTO visits (ref, ipaddress) VALUES ('$refsite', '$ipaddress')");
mysql_close($con);
?>
This is pretty much all the info i can give you short of doing ti all myself..
good luck
-G
Last edited by lynxus; 12-26-2009 at 06:44 AM..
|