Home » , » Make Your own PHP Hit Counter

Make Your own PHP Hit Counter


This is a basic site hit counter. What it does is take a few lines of code that open up a file called ( countlog.txt) and changes a simple number in it. First off, what you need to do is make a new ( .php) file in your text editor and place this code in it. The only thing you may need to change is the parts of the code that says ( /countlog.txt ). That’s only if you plan to put your files in a different directory. I put this in the same directory, so I put the ( / ) in front of ( countlog.txt )

<?php
/* counter */
/* opens countlog.txt to read the number of hits */
$data = fopen("/countlog.txt", "r");
$count = fgets($data,1000);
fclose($data);
$count = $count + 1;
echo "$count";
echo "hits";
echo "\n";
/* opens countlog.txt to change new hit number */
$data = fopen("/countlog.txt", "w");
fwrite($data, $count);
fclose($data);
?>

Save the file as ( counter.php ).
Now, on to the next part. Simply make a file named ( countlog.txt ) and put a ( 0 ) in it. Then save. Or, you could put whatever number you want to in the file. This is the number your, counter will start counting from. If your last hit counter was already at 22 hits, why start over? Just type in ( 22 ) in the
( countlog.txt) file!

To include the file in any page in your site all you have to do is include it. Here’s the code.

<?php
include("/counter.php");
?>

Or


<script src="/counter.php" type="javascript/text"/>

You may have to change the path on that as well, depending on what directory you put your file in. Or, you could just put the ( counter.php ) code inside of any page you want. It will work the same.

4 comments:

  1. This information is really useful. Keep sharing these kind of useful and informative article updates.

    PHP Training Institute in Chennai

    ReplyDelete
  2. Thanks for sharing this is such a very nice post. I really like it. thanks for spending time on it.
    Fantasy sports app development

    ReplyDelete
  3. Thanks for sharing this amazing content. it's very useful to me. The blog has a lot of information, the way you have clearly explained is really fantastic. Thanks a lot for this blog.

    Blockchain App Development Company

    ReplyDelete
  4. hi EveryonE!

    Are you been stuck for looking valid products or been scammed by scammers

    Here the Valid store available for all kind of tools,tutorials & Fullz with quality

    Learn hacking and spamming and do it on your own way & enjoy..........

    _______________

    1)FRESHLY SPAMMED USA FULLZ
    2)HACKING & SPAMMING TOOLS
    3)TUTORIALS
    _______________

    *Contact*
    *ICQ :748957107
    *Telegram : @James307
    *Skype : Jamesvince$
    _______________
    USA SSN FULLZ WITH ALL PERSONAL DATA+DL NUMBER
    -FULLZ FOR PUA & SBA
    -FULLZ FOR TAX REFUND
    *fullz/lead with DL num
    *SSN+DOB
    *Premium info
    *EIN PIN LEADS
    (TAX RETURN)
    *ELECTRONIC FILING LEADS

    ID's Photos For any state (back & front)
    ________________
    +US cc Fullz
    +(Dead Fullz)
    +(Email leads with Password)
    +(Dumps track 1 & 2 with pin and without pin)
    +HACKING & CARDING TUTORIALS
    +SMTP LINUX
    +SAFE SOCK
    +CPANEL
    +RDPs
    +Spamming Tutorial
    +SERVER I.Ps
    +EMAIL COMBO
    +DUMPS TUTORIAL
    +BTC FLASHER
    +KEYLOGGER COMP&MOB
    +EMAIL BOMBER
    +SQLI INJECTOR
    +ETHICAL HACKING TUTORIAL
    +GMAIL HACKING TUTORIAL
    +PENETRATION TESTING TUTORIAL
    +PayPal Cracker
    +BTC Cracker
    +BLUE PRINTS BLOCKCHAIN
    +EMAIL BLASTER
    +SMS SENDER
    +NORD VPN
    +ONION LINKS AND TOR BROWSER (LATEST VERSION)
    +DARK HORSE TROJAN
    +NETFLIX CHECKER
    +IP ROUTING
    +KEYSTROKE LOGGER
    +WESTERN UNION LOGINs
    +ALI BABA IPs
    +KEYLOGGER
    +SHELL SCRIPTING
    _______________
    *Let's do a long term business with good profit
    *Contact for more details & deal

    *Contact*
    *ICQ :748957107
    *Telegram :@James307
    *Skype : Jamesvince$

    ReplyDelete

Popular Posts

Post Category

Blog Statistics

Now online

Page views
Powered by Blogger.