Home Techindex PHP Registering simple statistics

 
 

PHP Registering simple statistics
Posted on: April 14, 2006 at 12:00 AM
Advertisement
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
 
GUI-Model Rainfall program
serves two purposes, based on the very simple problem of recording rainfall statistics. Show an example of separating the GUI from the model..., calculates statistics. //Note 1 /** Creates new form RainfallGUI
 
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
 
Registration timer expired, but client is still registering!
Registration timer expired, but client is still registering!  Registration timer expired, but client is still registering
 
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
 
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
 
$_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
 
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
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
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
 
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 define variable
php define variable  How to define a simple and a global variable in PHP
 
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
 
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. <
 
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
 
writing webservices in php
writing webservices in php  How to write a simple web service 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 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
 
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
 
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
 
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
 
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
 
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 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 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 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 mysql web application tutorial
php mysql web application tutorial  How to create a simple php mysql web application? Please post an example or tutorial
 
ZF Simple Form Creation
ZF Simple form creation: In the current tutorial we will study how to create a simple form in Zend Framework. We will use two ways to create  form... that phtml file as a simple html file. So, we can create a form in that file
 
php
php   what is php   PHP Tutorials
 
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
php  what is php
 
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
 
Registering DataSource with JNDI
.style1 { text-align: center; } .style2 { background-color: #FFFFCC; } Registering The DataSource With JNDI Java Naming Directory Interface (JNDI) Java Naming Directory Interface (JNDI) is an API of java technology which
 
php
php using javasript  how to set timer in php using javasript
 
Introduction to PHP Array
What is Array? An array in PHP is actually an ordered map, what is a map...;value) An example of an array is given below: <?php $first=array('Name... true  In above example <?php ?> is the delimiter, which
 
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
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
 
Advertisement

Related Tags for PHP Registering simple statistics:


Advertisements Advertisements
 

 

 

DMCA.com