#native_company# #native_desc#
#native_cta#

Revisited: Logging With PHP Page 2

By Tim Perdue
on December 10, 2000

The next step was getting the info into the tables. It would be
a perfect world if all pages were served through PHP and all of your
various web sites existed on one box. Unfortunately, I have an array
of servers scattered all over the country, and I want to collect this
info from every server for every page view 24 hours a day.
So that required me to use the 1×1 pixel GIF trick. I have a GIF
on every page on every server that looks like this:
<IMG SRC="http://www.yourserver.com/util/gif11.php3?c=4&s=phpbuildercom&b=77" 
height=1 width=1>
gif11.php3 is a simple script that resides on my central server.
I have included the source on the next page.
Since the gif is on each page, and is forced to load due to the random
number at the end (the b=xxxx), a request is sent back to the central
server for each and every page view.
If all of your pages and the database reside on one server, you don’t
need to use the GIF trick – you can insert the logging code into the
header of your page.
Here’s a drawing demonstrating what’s going on here:
diagram showing flow of Database from Web Server to Web Browser 
to Central Server to Database
There are 4 components in that drawing:
  • Remote web server
  • Web browser (user visiting that site)
  • Central logging server
  • Central database server
So the user visits the web server, gets a page get served up, and the browser
sees the 1×1 gif and requests it from the central server. The central
server then logs that information to make reporting easier.