This simple script creates an image that can be used on any page to display a hit counter. A session variable is used to ensure that the counter only advances once per browser session. In your html, put an <img> tag for the image, such as this one
PHP Code:
<img src="counter.php" alt="" style= "border-style:inset; border-width: 3; left: 20; top: 20; position: absolute;">
2) Now make a new file name "counter.php" without the " " in the directory where your site is.
3)edit the counter.php file
4) put the following code in it
PHP Code:
<?php
session_start();
if (!session_is_registered(\\\\\\\\\\\'hit_cnt_entry\\\\\\\\\\\')) {
session_register(\\\\\\\\\\\'hit_cnt_entry\\\\\\\\\\\');
= "0";
} else {
= "1";
}
= \\\\\\\\\\\'counter.dat\\\\\\\\\\\';
if (is_writable()) {
= fopen(,"r");
= fread(, filesize ());
fclose();
if ( == "0") {
= fopen(,"w");
= + 1;
fwrite(,"");
fclose();
}
= (strlen() * 8) + 8;
= @imagecreate (, 18);
= imagecolorallocate (, 255, 255, 255);
= imagecolorallocate (, 0, 0, 0);
imagestring (, 4, 4, 2, , );
imagepng ();
imagedestroy();
}
?>
the counter value in stored in a different file so
5) open notepad and put a number in it for example "100" this will be the number of hit that will be shown on the counter.
6) name the file counter.dat and upload it to the name directory where you created the counter.php file
and that's it your finished
You can cheat at any time just by changing the number in the counter.dat with notepad. i have also attached the counter.php and the counter.dat file ina zip
here is my finished file
http://www.gmgraphics.profusehost.ne...ter/index.html