eXTReMe Tracker





rainchild.org
Simple PHP Hit Counter
This simple hit counter is a really simple to setup and no MySQL database is needed.

To begin, paste the following in a new document:
<?php // This is the file where it tracks the hits
$file = "counter.txt";
// You shouldn't need to update anything else below.

// Check $file is writable
if(is_writable($file)){

// Get contents of $file
$fcontent = file_get_contents($file);

// Check file content -> register new hit value
if(!empty($fcontent)){
$ncontent = $fcontent+1;
}else{
$ncontent = 1;
}

// Open file and write in new amount
$fhandle = fopen($file, "w+");
$write = fwrite($fhandle, $ncontent);
fclose($fhandle);
// Close file stream

// Check new info writen correctly and then echo the new value
if(!$write){
echo("error updating counter");
}else
}

}else{
echo("- Check ".$file." exists.<br />");
echo("- Check the file is set to 777 permissions.");
}

?>
Save it as counter.php.

Next, make a blank document and save it as counter.txt.

Now upload both counter.php and counter.txt onto your server.
You now need to change the permission of counter.txt.
Chmod counter.txt to 777.

In order to display the hits use this code:
<? include("counter.php"); ?>
And.. you're done! It's that simple.


ELLEN. Canadian! 19.10.93.
I love.. SHINee. Dramas. Naruto. DBSK. Audition.
More? »

Top 5 Dramovies
1. Full House [K]
2. My Sassy Girl [K]
3. Last Friends [J]
4. Nodame Cantabile [J]
5. Silence [C]

Current Layout
#25 features the main cast of the Japanese drama, Last Friends. Image from here. Up since 29.05.08.
More? »

Browse
» Index » Ellen » You
» Site » Reads » Exits

Favorites
» Riku » Ray
» Maggie » Tenderly
» Janey » More?