PHP Registering simple statistics
Posted on: April 14, 2006 at 12:00 AM
Learn how to PHP Registering simple statistics.

PHP Registering simple statistics

Have you ever wanted to know who visited a certain page? For fun? For hit monitoring? For security reasons? If you answered yes to any one of those questions. This tutorial is for you ! In this tutorial I will teach you how to make a simple PHP Script that writes to an external log file statistics about the Visitor, and the date and time that they visited !

This program follows a simple algorithm as follows:
1. Grab the needed variables such as: Year, Month, Day, Hour, and Minute.
2. Open the log file.
3. Write to the log file all of the information.

Ok first we will use the getdate() command to grab all of the needed arrays.

   $datearray = getdate();

Next we will define in the Year, Month, Day, Hour, and Minute variables.

   $year = $datearray["year"];
   $month = $datearray["mon"];
   $day = $datearray["mday"];
   $hour = $datearray["hours"];
   $minute = $datearray["minutes"];

Now we choose define where this information will be written to. I chose access.log.

   $filename = "access.log";

Then we create a variable that carries the information about the file to write to.

   $fl=fopen($filename,'a');

Lastly we write the information to the text file.

   fwrite($fl, "[$REMOTE_ADDR on $month $day , $year at $hour :$minute]\n\r");
   echo ".\n";

The final code:

<?
  $datearray = getdate();
  $year = $datearray["year"];
  $month = $datearray["mon"];
  $day = $datearray["mday"];
  $hour = $datearray["hours"];
  $minute = $datearray["minutes"];
  $filename = "access.log";
  $fl=fopen($filename,'a');
  fwrite ($fl, "[$REMOTE_ADDR on $month $day , $year at $hour :$minute]\n\r");
  echo ".\n";
?>

The output in the text file should appear as so:

[IP ADDRESS on MONTH DAY, YEAR at HOUR: MINUTE]

Heres what it will look like when someone accesses it:

[192.168.10.5 on 3 26 , 2009 at 12 :08]

Well this is the end of the tutorial!
More Tutorials on roseindia.net for the topic PHP Registering simple statistics.
PHP Registering simple statistics
PHP Registering simple statistics Have you ever wanted to know who visited... ! In this tutorial I will teach you how to make a simple PHP Script that writes to an external log file statistics about the Visitor, and the date and time
 
simple class in php
simple class in php  example of simple class in PHP
 
ModuleNotFoundError: No module named 'simple_pypi_statistics'
ModuleNotFoundError: No module named 'simple_pypi_statistics'  Hi...: No module named 'simple_pypi_statistics' How to remove the ModuleNotFoundError: No module named 'simple_pypi_statistics' error? Thanks   Hi
 
php
Write a simple PHP program that display the days of week as per the system date using switch case statement.  Write a simple PHP program that display the days of week as per the system date using switch case statement
 
$_get php example - PHP
$_get php example  Explain the $_get method in php with a simple example. m a beginner
 
calendar in php code - PHP
calendar in php code   Any Idea to create a calendar for school in PHP? I need a simple nd handy code
 
PHP
files with the PHP PDF libraries Writing a simple PHP program You can embedded... of the page into web browser. Here is the simple example of PHP that prints "...PHP PHP stands for Hypertext Preprocessor; PHP is server-side scripting
 
Session management in php - PHP
Session management in php  I am creating a simple program in PHP to manage the session of user. It's basically a simple form that will allow a user to fill & submit the offer form after login. Please Explain me how can i create
 
PHP
PHP Services PHP refers to Hypertext Preprocessor, a general... scripting language. PHP generally runs on web server. It is competent..., Linux, Mac Os, Sun Solaris and others. But for processing the PHP code
 
php java
php java  why PHP is becoming more popular than java   PHP is more popular than Java because of following reasons: 1)PHP web hosting options are superior. 2)PHP provides rapid development and instant gratification
 
php session - Security
php session  My php session value is doesn't get. I checked the php... version. I think it seems to be error in Global registering.   Hi Friend, Please visit the following link: http://roseindia.net/php/php
 
PHP Getting Started With PHP Tutorial
PHP Getting Started       Learn the basics of PHP with this quick and simple tutorial. Designed for the very beginners. What is PHP?ADS_TO_REPLACE_1 It is an open source scripting
 
Registration timer expired, but client is still registering!
Registration timer expired, but client is still registering!  Registration timer expired, but client is still registering
 
simple eg
simple eg   <?php</li> $string = ?Hello Users?; print (?Welcome to Roseindia, I want to greet $string?); print (??); $string = ?Bye Bye!?; print (?OK meet you soon, $string?); ?> in this program we get a error at line
 
PHP Examples
In this section of PHP examples, the new bees will learn the basic examples... as assesing our codes, the programmers can develop simple to very complex programs. In this PHP example section, we have tried to cover the whole range of PHP
 
Javascript and PHP
Javascript and PHP  Hello, I want to know how to call javascript function inside PHP code . Could you please tell me the way to call it? Thanks   Here is a simple example of php that calls javascript function. <
 
php define variable
php define variable  How to define a simple and a global variable in PHP
 
PHP Array
to stored values in key value pair. Here is simple example of PHP array: $fruit...PHP Array In this page we will learn about PHP Array. We will also understand how to use PHP Array in your PHP program. The PHP Array is very useful
 
PHP ini
PHP ini       PHP provides us so... customize the behavior of php. Using this file maintaining PHP will be as easy... can configure all PHP's runtime configurations. It is also better
 
PHP Installation, Installing PHP on windows
Developing the sample example Now we will develop a simple php file...PHP Installation Learn how to install PHP on your windows and then test the server with a php script. In this section we will learn the Installation
 
PHP - Ajax
PHP  How can ajax is used in php,plz expalin with example.  Hi friend, Code to solve the problem : Ajax...); } Ajax Example  This very simple Ajax Example retrieves
 
php do while example
php do while example  Simple example of do while loop in PHP
 
file_exists php not working
file_exists php not working  file_exists php not working. Please give me the simple example
 
php parse ini file
php parse ini file  I need a simple and easy example to Parsing an ?advanced? INI file with PHP
 
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
 
com.yahoo.vespa - statistics version 7.89.24 Maven dependency. How to use statistics version 7.89.24 in pom.xml?
com.yahoo.vespa  - Version 7.89.24 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 7.89.24 of statistics in pom.xml? How to use statistics version 7.89.24 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 7.348.26 Maven dependency. How to use statistics version 7.348.26 in pom.xml?
com.yahoo.vespa  - Version 7.348.26 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 7.348.26 of statistics in pom.xml? How to use statistics version 7.348.26 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 7.7.18 Maven dependency. How to use statistics version 7.7.18 in pom.xml?
com.yahoo.vespa  - Version 7.7.18 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 7.7.18 of statistics in pom.xml? How to use statistics version 7.7.18 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 7.117.37 Maven dependency. How to use statistics version 7.117.37 in pom.xml?
com.yahoo.vespa  - Version 7.117.37 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 7.117.37 of statistics in pom.xml? How to use statistics version 7.117.37 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 6.221.26 Maven dependency. How to use statistics version 6.221.26 in pom.xml?
com.yahoo.vespa  - Version 6.221.26 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 6.221.26 of statistics in pom.xml? How to use statistics version 6.221.26 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 6.271.25 Maven dependency. How to use statistics version 6.271.25 in pom.xml?
com.yahoo.vespa  - Version 6.271.25 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 6.271.25 of statistics in pom.xml? How to use statistics version 6.271.25 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 6.162.10 Maven dependency. How to use statistics version 6.162.10 in pom.xml?
com.yahoo.vespa  - Version 6.162.10 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 6.162.10 of statistics in pom.xml? How to use statistics version 6.162.10 in pom.xml? Learn to use this dependency
 
com.yahoo.vespa - statistics version 6.228.142 Maven dependency. How to use statistics version 6.228.142 in pom.xml?
com.yahoo.vespa  - Version 6.228.142 of statistics Maven dependency? How to use  com.yahoo.vespa  - Version 6.228.142 of statistics in pom.xml? How to use statistics version 6.228.142 in pom.xml? Learn to use
 
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
 
Best PHP tutorial for beginners
want to know: a) How to install PHP? b) How to create simple program and test? c) Learn basics and advanced concepts of PHP programming language in very less time...Best PHP tutorial for beginners  Hi Friends, I want to learn PHP
 
PHP Expression
PHP Expressions: In every language expression plays a vital role, in PHP...; Expression functions in PHP:ADS_TO_REPLACE_2 PHP Regular Expression Example: <?php function disp()ADS_TO_REPLACE_3 { $a=23; return $a;ADS
 
Why PHP ?
6.    PHP is easy to learn : PHP is extremely simple...Why PHP? Reasons to use PHP are given below: 1.    PHP is open source, free to download and use : PHP is free and you can download
 
php
php   what is php   PHP Tutorials
 
sql php array
sql php array       SQL PHP Array support simple dimension array. The SQL PHP Array is used... The Tutorial illustrate an example from 'SQL PHP Array'. To understand
 
PHP Array
but there could be different ways to define it. In simple words an array is used....[...] or associative. In PHP programming arrays are generally used for either... for each value.ADS_TO_REPLACE_3 In this series of PHP tutorial we have talked
 
PHP convert week number to days or month - PHP
PHP convert week number to days or month  Small, simple and easy code that can do following task: 1.Convert Week Numbers to Month 2.Convert Week to Date Generally, we use the date time object in PHP to convert the date
 
php
php  what is php
 
org.webjars.bowergithub.vaadin - vaadin-usage-statistics version 2.0.4 Maven dependency. How to use vaadin-usage-statistics version 2.0.4 in pom.xml?
-statistics Maven dependency? How to use  org.webjars.bowergithub.vaadin  - Version 2.0.4 of vaadin-usage-statistics in pom.xml? How to use vaadin-usage-statistics version 2.0.4 in pom.xml? Learn to use this dependency in your project
 
org.webjars.bowergithub.vaadin - vaadin-usage-statistics version 1.1.0-beta1 Maven dependency. How to use vaadin-usage-statistics version 1.1.0-beta1 in pom.xml?
-statistics Maven dependency? How to use  org.webjars.bowergithub.vaadin  - Version 1.1.0-beta1 of vaadin-usage-statistics in pom.xml? How to use vaadin-usage-statistics version 1.1.0-beta1 in pom.xml? Learn to use this dependency
 
org.webjars.bowergithub.vaadin - vaadin-usage-statistics version 1.0.0-optout Maven dependency. How to use vaadin-usage-statistics version 1.0.0-optout in pom.xml?
-statistics Maven dependency? How to use  org.webjars.bowergithub.vaadin  - Version 1.0.0-optout of vaadin-usage-statistics in pom.xml? How to use vaadin-usage-statistics version 1.0.0-optout in pom.xml? Learn to use
 
ile_exists php
ile_exists php  i have written a simple php code where i used the file_exists. But somehow it's not working. Please suggest Thanks
 
php download file from ftp
php download file from ftp  Need to download files from ftp using php. a simple example
 
PHP Introduction
for their website. The PHP stands for PHP: Hypertext Preprocessor. The php program is simple text file with the .php or .php5  extensions. You can use... The quick introduction to the PHP programming language PHP is server
 
php
php using javasript  how to set timer in php using javasript
 
php
php  i want to know about php and php plateform required software to make php program and database that used in php program?   Please visit the following link: PHP database
 
Ads

Related Tags for PHP Registering simple statistics:


Ads

 
Advertisement null

Ads