Create a Unique Counter

Create a Unique Counter

Posted By: mitsurug1 on Mar 06, 2005

Create a unique counter for your site

Put this code in the top of the document, before all HTML code.
PHP Code:
$logfile="/counter.log";
$counted=$_COOKIE["counted"];
if(!
$countedsetcookie("counted",1,time()+86400); 
Now paste this code were you want the counter to appear, it's text only.

PHP Code:
$num=file_get_contents($logfile);
if(!
$counted){
$fp=fopen($logfile,"w") or die("OMFG");
$num++;
fwrite($fp,$num);
fclose($fp);
}
echo(
$num); 

Now create a file called counter.log and CHMOD it to 646.
  • Comment on this tutorial
  • View the Printable Version

Posted On: Mar 06, 2005

Hits: 5068 - Unique: 3889

Advertise Here!

Quick Tutorial Search

Our Popular Tutorials

Signature Backgrounds

Abstract Wave Technique

Abstract Airbrushing

Cinema 4d Materials Tutorial

Rusty Metal Plate

Dark Art Guide

Trendy Grunge Background

Video Sigs