Jump to content

Need help with Tracking Hit Count


zelllibin

Recommended Posts

i have a code here.. which count number of visitors ..

i was wondering how to i code it so that it could track click of links from my webpage.

 <?php
// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"; 
$page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", "");
$referrer = $_SERVER['HTTP_REFERER'];
$datetime = mktime();
$useragent = $_SERVER['HTTP_USER_AGENT'];
$remotehost = @getHostByAddr($ipaddress);

//create a log line
$logline =$ipaddress.'|'.$referrer.$datetime.'|'.$useragent.'|'.$remotehost.'|'.$page . "/n";
//logs folder
$logfile = 'logfile.php';

// Open the log file in "Append" mode
if (!$handle = fopen($logfile, 'a+')) {
die("Failed to open log file");
}

// write logline to logfile
if (fwrite($handle $logfile) === false
{ die ("The File Cannot Be Logged");
}
fclose($handle)

?>

Link to comment
https://forums.phpfreaks.com/topic/134840-need-help-with-tracking-hit-count/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.