Jump to content

visitor hit


sungpeng

Recommended Posts

$going =$_SERVER["REMOTE_ADDR"];
$time=date(y).date(m).date(d).date(h).date(i).date(s);
$str="INSERT INTO track(chtime,visitor,pages) values ('$time','$going','index')" ;
mysql_query($str) or die('Error insert query failed');

The above code will track the user IP address whenever a visitor hit my pages. Can check how to stop repeated visitors from activate the above code or if refresh button is hit, the above code will not activate. It will work only work once to get exact number of new visitor.

Link to comment
https://forums.phpfreaks.com/topic/153814-visitor-hit/
Share on other sites

and if I want to count the number of time per visitor hit the pages using $_cookie, how to code?

$going =$_SERVER["REMOTE_ADDR"];
setcookie("user", "$going");

 

$oneyear = time() + (365 * 24 * 60 * 60);
$currenthits = $_COOKIE['userhits'];

setcookie('userhits', $currenthits+1, $oneyear);

Link to comment
https://forums.phpfreaks.com/topic/153814-visitor-hit/#findComment-808450
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.