Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Create a new empty .txt file and name it "mysimplecounter.txt"
    DO NOT forget to CHMOD .txt file 777 - 666 also is fine

    PHP Code:
    <?php 
    $fp 
    fopen("mysimplecounter.txt","r"); 
    $count fread ($fpfilesize ("mysimplecounter.txt")); 
    fclose($fp); 
    $count++; 
    $fp fopen("mysimplecounter.txt","w"); 
    fwrite($fp$count); 
    fclose($fp); 
    echo 
    "Total Visitors: $count"
    ?>
    The PHP Code abouve copy it to a file (eg counter.php) and include it to your website.

    Code Explanation :

    $fp = fopen("mysimplecounter.txt","r");
    It will open our .txt file for reading

    $count = fread ($fp, filesize ("mysimplecounter.txt"));
    Reading data and store it in a string

    fclose($fp);
    Closes the opened .txt for protection, as it will not be used right now.

    $count++;
    It adds +1 to $count

    $fp = fopen("mysimplecounter.txt","w");
    It opens again our .txt file to store the new visitors 'number.

    fwrite($fp, $count);
    Writing...

    fclose($fp);
    Closing for safety the writen .txt

    echo "Total Visitors: $count";
    Displays the total number of visitors.

    See it in action :
    http://www.wmp.gr/count/count.php
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:31 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com