Honesty Rocks! truth rules.

Hit Counter simple hit counter

HOME      >>       General Discussion

awarkops

ok just copy this code to the location you want the counter on

PHP Code

<?php  $file = 'counter.txt';

  if(!file_exists($file))
  {
      $handle = fopen($file, 'w');
      fwrite($handle, 0);
      fclose($handle);
  }

  $count = file_get_contents($file);
  $count++;

  if(is_writable($file))
  {
      $handle = fopen($file, 'w+');
      fwrite($handle, $count);
      fclose($handle);
  }
  else
  {
      echo 'Could not increment the counter!<br />';
  }

  echo number_format($count).' Hits';
?>

open notepad and save it as counter.txt then upload it to the director you put the code on the php page a set the permission to 777

when adding this code to you page make sure you save you page as name.php
and not as name.htm or name.html or if you have php activation in html u can just save it as html

im cant remember how to activate php in html if some one can tell me it will help

courage

well i can say its not the easyest, but realy helpful! now people can't cry about couldn't get a hit counter :)


bucksta

hit counters are easy to make. all you need is some php knowledge and thats all. its harder making a mySQL hit counter but somehow it turns out better.


Cerebral Stasis

I assume this counter actually counts specific hits, so if one sits in a page and refreshes, the counter will continue to go up, right? I, personally, am only interested in counters that actually count unique visitors or at least unique hits. Perhaps you could create a tutorial explaining how to create a counter that works that way.This "tutorial" may be quite useful, but I'm afraid to say it can hardly count as a tutorial, since it doesn't teach one anything, nor does it explain what the individual parts mean or do.


BD Photography

ok just copy this code to the location you want the counter on

 

PHP Code

 

open notepad and save it as counter.txt then upload it to the director you put the code on the php page a set the permission to 777

 

when adding this code to you page make sure you save you page as name.php

and not as name.htm or name.html or if you have php activation in html u can just save it as html

 

im cant remember how to activate php in html if some one can tell me it will help

213642[/snapback]

that sounds cool and all. however i jsut dont like other people to see how many other people have visited my site. i like the hit counters taht jsut allow you so see how many people visited your site and at what time of teh day.

bucksta

cool. il try it since i have a blank web site with nothing to put on the main page. a hit counter sounds good.


wassie

omg, then you have a emty website with only a hit counter 0.o


Dart-kun

It's a good tutorial if not a tad short, and pretty simplistic.I recently searching for a hit counter aswell, and ended up finding one that records unique hits each day. So if someone was to Visit my site, it would count 1. No matter how many times they refreash with 24 hours, another hit won't be counted. But after 24 hours, it would raise to 2. It's pretty nice, was just a PHP counter, but it was good. But I ended up losing it, and not being able to find it.Perhaps next time you could make one like this? I'm sure alot of people would like it aswell.


apollo

Hello. I`m new memmber. As courage saied it`s a bit hard for new member, but i`m not begginer with HTMl and PHP, but anyway, it`s not working for me.... Thnx, apo!


snlildude87

Nice code, but why would you make your own when you can have another hit counter done professionally from a site such as statcounter.com that counts unique visitors and shows specific details about each visitor?


eee

thanks on the tutorial ill try and it and see how it works out thanks man...


final_fantasy

thanks man :(


xavierrd

:)Seems easy and simple, thanks.


Kioku

This is deffinietely better than the "free counter" piece of junk I've been having to use for quite a while. Thanks.


zwek

Nice smple and good tnx