TechiWarehouse.Com


Top 3 Products & Services

1.
2.
3.

Dated: Sep. 09, 2004

Related Categories

PHP Programming

OK guys, this script is a simple file based counter. This is meant for sites that do not run a db and instead, use a file and a cookie. It isn't the best I've seen but it's simple. Consider this as a tutorial.

Just create a file called counter.txt and put this where you want to display the counter.

Remember to set the permissions on counter.txt so that your webserver can write to the file.

<?
$visitor_ip = $HTTP_COOKIE_VARS["user_ip"];
$counter = "counter.txt";
$counter_file_line = file($counter);

if(!$vistor_ip)
{
setcookie("user_ip", $REMOTE_ADDR, time()+360000);
$counter_file_line[0]++;
$cf = fopen($counter, "w+");
fputs($cf, "$counter_file_line[0]");Flat File Counter
fclose($cf);
}
elseif($vistor_ip != $REMOTE_ADDR)
{
$counter_file_line[0]++;
$cf = fopen($counter, "w+");
fputs($cf, "$counter_file_line[0]");
fclose($cf);
}
?>

Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!


Previous Article

Next Article


puvi's Comment
a e i o u
17 Wed Aug 2011
Admin's Reply:

 Vowels :) 






Facebook