Skip Navigation LinksHome > Categories > Code from a Category

Our own site traffic statistics



User Name: serfcompany
Name: Serf
Contact Me: www.datawebcoder.com
Home Page: www.datawebcoder.com
php,mysql,javascript,html,css. Preferable working with Zend Framework. Good know javascript. I worked with various, javascript frameworks such as(jquery, YUI3, extjs, sencha touch). [More]
Viewed Times: 159
Add Date: 03/18/2012
This article is about how to use PHP and MySQL, you can organize the collection of statistics of visits to your site.And the feature statistics obtained as a result of the script will be that you get the statistics about each visitor individually, find out what pages he visited, which browser used, how much time spent on your site and much more.

First you need to create a table in your database (MySQL), we call it, for example "counter", its structure will look like this:



After you create a table directly proceed to write the script responsible for filling out and display the collected information.


First we need to have a "register" the user can use for this session:



When using this method requires that the script would have worked up to the counter output to the user's browser of any information, or this piece of code can be made to the top of the main script, and the counter include'it in the desired location.


Now the user is registered and we have to get information about him and that he had visited pages.
To do this, PHP has many features:



The user information received, and now it needs to be added to the table, for this to start to connect to the database and select our table:



With MySQL connected, you now need to fill in the data table, this will create a few new features:



As a result, we have to add just a couple of lines and the script will be ready:



But not everyone is as good as it might seem a novice programmer, the fact that the script will be very hungry, and if you are the owner of the site with a lot of traffic, then this script may cause significant absorbed by the increase in traffic.


For those who may have failed to gather news of the script together, bring it full source code:


counter.php


To display the statistics you may need another script:


vizit_info.php


shabl.htm

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Details**:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
 
    
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.