[TuT] PHP Counter

KilkKilk Junior MemberShared Hoster
Tutorial on how to make a php counter-


First just make a blank file called counter.txt


Then make a file called counter.php with the fallowing in it-
<?php
$count = ("counter.txt");
//now this is where we open the file
$visits = file($count);
//this adds 1 hit
$visits[0]++;
//Now open the counter
$fp = fopen($count , "w");
//put the new count value into the txt file
fputs($fp , "$visits[0]");
//close the file
fclose($fp);
//display the count
echo $visits[0];
?>

Then upload both to your webserver, then CHMOD the counter.txt file to 777

And add this code to your webpage where you want the counter to show up-
<?php
include ("counter.php");
?>

And tada! There is your free to use web counter!

Comments

  • BursteffectBursteffect Beginner Link Clerk
    Noice when i make a forum i'll be using this :D.
  • madelinekimmadelinekim Beginner Link Clerk
    This is really very nice tutorial you share here.It is really very nice for me to learn how to create php counter. I am just start to learn php so that this is really very useful for me to earn php counter.
    Photoshop courses in melbourne
Sign In or Register to comment.