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.


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";
  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:


Heres what it will look like when someone accesses it:

[ on 3 26 , 2009 at 12 :08]

Well this is the end of the tutorial!
More Tutorials on 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
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
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
$_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
Registration timer expired, but client is still registering!
Registration timer expired, but client is still registering!  Registration timer expired, but client is still registering
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
Generate PDF files with the PHP PDF libraries Writing a simple PHP program... it by typing the url of the page into web browser. Here is the simple example of PHP...PHP PHP stands for Hypertext Preprocessor; PHP is server-side scripting
php define variable
php define variable  How to define a simple and a global variable in PHP
How can we get hibernate statistics?
How can we get hibernate statistics?  Hi, How can we get hibernate statistics? Thanks,   Hi, The Hibernate statistics is one... to collect statistics. It implements primarily to development (staging) environments
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 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? It is an open source scripting language which can
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
create a simple form
create a simple form  Helo. i am learning php, and i need help creating below for. Its simple but i need help. Create a form that contains: 1. Name, textbox 2. Submit button If the user inputs the Name textbox and clicks
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
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:
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. <
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
php do while example
php do while example  Simple example of do while loop in PHP
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
file_exists php not working
file_exists php not working  file_exists php not working. Please give me the simple example
trafic site statistics - Java Server Faces Questions
trafic site statistics  Hello, Does the framework JSF work for creating web pages containing 3D entities (like 3DCharts)and displaying web trafic statistics using data coming from a full database ? if it does, how can we
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 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 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 - 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
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 download file from ftp
php download file from ftp  Need to download files from ftp using php. a simple example
sql php array
sql php array       SQL PHP Array support simple dimension array. The SQL PHP Array is used... illustrate an example from 'SQL PHP Array'. To understand and grasp
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 Expression
PHP Expressions: In every language expression plays a vital role, in PHP... functions in PHP: PHP Regular Expression Example: <?php function disp...: <?php function disp() { echo $a=23; } disp(); ?> Output
PHP Simple password generator
PHP Simple password generator In this tutorial I will be showing you how to create a random password using nothing but loops and random letters. For extra... need it, you decide. The complete code is here: <?php // filename
Version of com.keyholesoftware>khs-spring-boot-api-statistics-starter dependency
List of Version of com.keyholesoftware>khs-spring-boot-api-statistics-starter dependency
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 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 mysql web application tutorial
php mysql web application tutorial  How to create a simple php mysql web application? Please post an example or tutorial
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... by commas. i.e.  Syntax of defining array () in PHP $arrayname = array ( "
Why PHP ?
is easy to learn : PHP is extremely simple for newcomer, but offers many...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 Basics Tutorial Index
* Write simple PHP program to display the current date...PHP Basic Tutorial: Learn the Basics of PHP scripting through our PHP Basic Tutorial series. The PHP Basic Tutorial is design for new programmers who want
php   what is php   PHP Tutorials
PHP Introduction
Another simple charting library in PHP. JpGraph Use this library... Develop and test PHP applications? PHP is simple programs are simple text...In this section I will introduce you with the PHP scripting language. The PHP
Maven Dependency khs-spring-boot-api-statistics-starter >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.keyholesoftware >> khs-spring-boot-api-statistics-starter version1.0.1 in your project
php  what is php
php using javasript  how to set timer in php using javasript
problem from registering a data in database with servlet - JSP-Servlet
problem from registering a data in database with servlet  Hi Rose, i created a servlet to validates ten user details in the database, if present it should return "You have already registered" but if not it should take all
PHP PHP Triad Tutorial
PHP-Triad Tutorial      ... on the PHPTriad server. PHPTriad is a software package which installs PHP.../projects/phptriad/. To download the latest version visit the office website of the 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
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

Related Tags for PHP Registering simple statistics:


Advertisement null