![]() |
|
|
|||||||
| PHP - Code Snippets Functional Code Snippets that other people may find useful. Post them here! |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
If you want a REAL basic hit counter just open a file and everytime someone goes to the website increment that number in the file. In any case you need to store the number of hits somewhere. Usually you'll want to use something like cookies or IP addresses so you don't count the hits again when someone clicks reload a thousand times.
|
|
|||
|
I do not know php, but hope this helps
http://www.tutorialstream.com/tutori...ts_counter.php http://www.tizag.com/tools/counter.php |
|
|||
|
So, here is what your going to do... (taken from http://www.tutorials-expert.com/tuto...out-MySQL.html)
1) Create a file called visits.txt and simple type a 0 and save the file to your server. 2) Create a file called counter.php and enter in the following code PHP Code:
HTML Code:
<html> <body> <?php include 'counter.php'; ?> </body> </html> |
|
|||
|
Thats true but in text file you will get counter incremented by one when user will refresh the page. I would prefer to set the variables at page load first time and then check for that variable using isset() to check whether user is refreshing page or not.
|
|
|||
|
or, set a cookie... it's not 100% foolproof, but it works.
|
|
|||
|
My own opinion is that it is better to store such info a table into the database. in that way you could store not only that somebody has hit the page but also and information about the system that he/she is using and the sessionID, in that way you will be able to track the not only the count of the pages that are hit but also and the individial sessions. Also you could store and the ip and domain from that the user is accessing you.
Beside that technique the best solution to track the users that are using your page of course is made by Google. Check the google analytics: http://www.google.com/analytics/ Best Regards, Yani |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|