Webpage Counter

Code:
<?php
$fp=fopen("hits.txt","r");
$count=fgets($fp,1024);
fclose($fp);
$fp=fopen("hits.txt", "w");
$count++;
fputs($fp, $count);
fclose($fp); 
echo $count;
?>

Oh and you should check your site out in Firefox. (Or not if you don't want more work to do...)

Also wrong forum i believe. And no homework threads. And use google in future.

Other than that, good luck. :)
 
Last edited:
You need to update the counter too
emot-ssh.gif
 
Yeah might help if i paid more attention to what i was doing. Oh well... That *should* work now i believe.
 
Whoops, had made a bit of a mistake on line 7... Updated it though now, i gave it a go and it worked fine for me. Just put that in your page where you want the number of hits to appear.

Also this assumes the file you're using to store the count in is called hits.txt, and you need to chmod it to 666.

If you just save it, and make it it's own file, you'll just get the number incrementing each time... working link
 
Ok im not sure what you meant by the last bit.

Where in the page do i copy it anywhere i presume?

Dont get the bit with the txt file...
 
Ignore my last post me being stupid.

Got i to work bar it displays a little 2,3,4 etc on the home page how do i get rid of this?
 
Back
Top Bottom