Nov 21, 2009

Php Hit Counter - record your visitors...

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

Php Hit Counter - record your visitors...

cragllo
All you do is copy this code into the page you want to display it on.

CODE
<?php
$counterfile = "counter.txt";
$counter = file("$counterfile");
$c = $counter[0];
if (strlen($c) == 0)
{$c=0;}
$c=$c+1;
$a = fopen("$counterfile", "w");
fwrite($a, $counter = "");
fputs($a, $c);
fclose($a);
echo ("$c");
?>

Make a file called 'counter.txt' in the same directory as the page the code is on.
Remember to CHMOD your txt file to 666. (change the permissions to 666)

Comment/Reply (w/o sign-up)

triplebtalk
Wow thats even better than the other tutorial I read on this site. Thanks for making such a simple PHP counter. You could explain what each function does, but otherwise, great job.

Comment/Reply (w/o sign-up)

contactskn
Dear friend its much more easier than the previous one so it will be helpfull for many out here and definitely be tried by many. Thank you very much such a good code set. 

Comment/Reply (w/o sign-up)

webishqiptar
yes very simple hit counter, but you cannot integrate it on every page. You need a new script for every directory, and I like hit counters who are integrated with databases.

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : php, hit, counter, record, visitors

  1. <?php ?> Unique Visitors Script
    Flat file unique visitors script (no sessions) (2)
  2. Php Counter
    (3)
    is it possible to use php to make a counter on a website and if it is does anyone know code for an
    effective one ??....
  3. Hit Counter
    simple hit counter (0)
    ok just copy this code to the location y QUOTE   $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!
    ';   }   echo number_format($count).' Hits'; ?> open notepad and save it as
    counter.tx....
  4. Visitors Online
    With PHP (no MySQL is needed) (9)
    Another script, which shows the visitors onlineat the moment in your site. This script was not made
    by me, I just think it will be very usefull to u. CODE $timeout = 15; // change it. It is the
    timer which will delete the member of  online list (in minutes) if (!$datei) $datei =
    dirname(__FILE__)."/online.txt"; $time = @time(); $ip = $REMOTE_ADDR; $string = "$ip|$time\n"; $a =
    fopen("online.txt", "a+"); fputs($a, $string); fclose($a); $timeout = time()-(60*$timeout); $all =
    ""; $i = 0; $datei = file("online.txt"); for ($num = 0; $num $pieces = explode("|",$datei....
  5. Visitors Counter
    With PHP (no MySQL needed!) (4)
    Well, here we will make an hit counterusing php and an *.txt file. This script is so simple, but
    very usefull. First, le'ts make an file called counter.php, with the following codes inside:
    CODE $file = 'counter.txt'; // this is the file where the number of visitors will be
    written $fopen = fopen("$file", "r"); // open the text file $count = fread($fopen, 1024); // read
    the text file fclose($fp); // close the text file $count = $count + 1; // add one more hit echo
    "$count"; // print the number $fopen = fopen("counter.txt", "w"); // open the file again....
  6. One More Tut 4 U :)
    Link counter (0)
    Well, in this tut, I'll show you how to do an simple link counter, with only one count for each
    IP and the date when the link were clicked. Just remember, this is only one way to do it. First,
    create an mysql database called 'links', with 2 table: first table will be called
    'links', with the columns: id, title, ref and clicks. The other one will be 3 columns and
    will be called links_info: id, ip and date. Just remember that the columns 'id' of this
    second table IS NOT auto-increment. Here is the code of the file which will count the clicks, ....
  7. Show Visitors Ip Addresss
    (9)
    Want to show the IP of the visitor to your site? All you have to do is add this code to your page
    where you want the IP to be shown: CODE ?> ....
  8. Does any one have a php counter script?
    Free counter script? (15)
    Does anyone know of a good counter script i could use to display the number of clicks/hits on a
    download link on one of my sites?....

    1. Looking for php, hit, counter, record, visitors

Searching Video's for php, hit, counter, record, visitors
See Also,
advertisement


Php Hit Counter - record your visitors...

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com