HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Website Counter
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
veasna



Joined: 15 May 2007
Posts: 56

PostPosted: Tue Nov 06, 2007 5:14 pm     Website Counter Reply with quote

If someone view my website, and other one view my
website too. Can you tell me how to count amount of
website viewer?

Thanks
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Sun Dec 02, 2007 11:07 am     Reply with quote

Yes you can, you would do it like this,
Make a text file on your server named "views.txt". In the text file, type the number 0 and save it. Put "views.txt" in the same folder as the page you want to count the views on. Place the following code in the PHP file of the page you want to count the views on.
Code:
<?
$file_name = "views.txt";
$file_a = fopen($file_name, 'r');
$views = fread($file_a, filesize($file_name));
fclose($file_a);
(int)$views;
$views += 1;
$file_b = fopen($file_name, 'w');
fwrite($file_b, $views);
fclose($file_b);
?>
<center style="position: absolute; bottom: 0px;">Page Views: <?echo $views;?></center>
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial