|
|
|
Simple
Hits Counter
Step 1: Open Notepad Leave it blank click File>Save as..
and put hits.txt and save it. Then upload it to you website
directory, make sure to put it in the same folder as the php
page containing the hits code. Also Note: You must CHMOD this
file to 777. I will add a Permissions Tutorial to the FTP
category ASAP, for those of you that dont understand CHMOD.
STEP 2: Add the following code to a blank file name it
counter.php.
CODE |
<?php
$filename = "hits.txt" ;
$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo $hits;
$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename)) ;
fclose($fd) ;
$fd = fopen ($filename , "w");
$fcounted = $fstring."n".getenv("REMOTE_ADDR");
$fout= fwrite ($fd , $fcounted );
fclose($fd);
?>
|
STEP 3: Now to make this counter show up simply add the
following code on any .php page. REMEMBER renaming a .html
document to .php does not effect the html.
CODE |
Total Visitors: <?php include('url/to/file/counter.php');
?>
|
NOTE: Remember to change 'url/to/file/counter.php' to the
correct path of your counter.php file.
Tutorial by Xtasy
|
|