...

View Full Version : Counting Visitors??



php_stud
04-15-2004, 02:36 AM
i've seen php codes in this forum to count the times that your site has been visited by saving it to a textfile... i tried it and it works... then again, i think to make it more organize, i save it to a database and add a field date and time just to identify the traffic in detail (actually, i've tried putting counters in all my pages (?? quite easy doing that way)... so, is it possible to record the ipaddress of your visitor just to identify the unique hits ? thanks.

raf
04-15-2004, 02:48 AM
Sure it's possible. You can get the ip with


if (isset ($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$UserIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else {
$UserIP = $_SERVER['REMOTE_ADDR'];
}


But you do realise that your webserver logfiles contain all that info + that there are loads of tools to proces and analyses your logs ...

php_stud
04-15-2004, 02:55 AM
yes, i know that... but the webserver is located in the other department... i just have link (a shared folder) to our site and my databases ... and they wanted me to count the site visitors on my own... anyway, thanks for your help raf!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum