cragllo
Dec 6 2004, 04:31 PM
| | 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
Jan 2 2009, 05:01 PM
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
Jan 3 2009, 09:04 AM
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
May 2 2009, 07:55 PM
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)
Similar Topics
Keywords :
Php Counter Visitors- 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 ?> ...
<?php ?> Unique Visitors Script
- Flat file unique visitors script (no sessions) (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 ??...
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...
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...
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?...
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...
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, ...
Looking for php, hit, counter, record, visitors