24, July 2008

A simple counter in PhP - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: A simple counter in PhP
« previous next »
Pages: [1] Print

Author Topic: A simple counter in PhP  (Read 1097 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7974
40801 credits
Members referred : 3



« on: Aug 26, 2005, 03:09:04 PM »

Here is the code for a very simple counter that you can add to your site :

Code:
<?php
if(file_exists("hits.txt"))
{
    
$hits file_get_contents("hits.txt");
}else{
    
$hits=0;
}
$hits++;

$ha fopen("hits.txt""w");
fwrite($ha$hits);
fclose($ha);
?>

You can add it to the .php page that you want to count, plus you can add this code if you want it to be visible :

Code:
<?php
echo $hits." visitors";
?>

« Last Edit: Aug 30, 2005, 03:36:13 PM by Nikolas »

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Novice Spammer
***
Posts: 100
103 credits
Members referred : 0



« Reply #1 on: Sep 01, 2005, 09:37:57 PM »

I actually prefer the hitcounters that use a database. I feel you can do much more with a database and text files. Its almost a bias. But its good code though for someone who doesnt have a database to work with.
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7974
40801 credits
Members referred : 3



« Reply #2 on: Sep 02, 2005, 11:49:22 AM »

The best is having a log analyzer, but all these funzy stuff are not usefull for small sites. I mean you don't need a sofisticated statistics program when you have 30 visits per day...

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Credit Thief
.com pimp
*****
Posts: 1118
0 credits
Members referred : 0



« Reply #3 on: Sep 05, 2005, 08:10:28 AM »

Interesting, I'm going to try it out. Perfect for me.

Novice Spammer
***
Posts: 100
103 credits
Members referred : 0



« Reply #4 on: Sep 08, 2005, 07:32:10 AM »

Yea I guess you are right, small sites dont need an advanced stats tracker.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2
Tags : php databases Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: A simple counter in PhP
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 24, 2008, 11:10:38 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.712
Total Topics: 7.376
Total Members: 3.706
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: FortuneBeach

25 Guests, 6 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.