Well that should write as soon as that php is requested...

BUT U might want to put some file locking in there to make sure 2 people
don't visit at the exact same time and corrupt your Vistor_Log.txt

BTW If are using apache a better option might be to look into the custom log
files it can make, I think it can do what you are trying to do in PHP

Andrew
----- Original Message -----
From: "Martin Clifford" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 10, 2002 4:36 PM
Subject: [PHP] Visitors Log Help


Hi all!

I am trying to build a Visitor_Log.txt file for my page, which will write
specific information about users that visit the page (time of day they
visited, browser they are using, operating system, etc) to a txt file on my
server.

My question is... how do I write these values to the file as soon as they
access the page?  I'm very comfortable with using JavaScript to get user
information, but I know that PHP also has built-in functions to get user
information as well... would I do something along the lines of...

<?

$TheFile = "log.txt";
$Open = fopen($TheFile, "a");
if($Open)
{
  fwrite($Open, "$HTTP_USER_AGENT\n");
  fclose($Open);
}

?>

If someone loaded a page with that in it, would it write to the file as soon
as it's accessed and interpreted, or would some action have to take place to
make it run?  I won't ask which PHP Variables can be used to get user
information, I can find that information in the Manual... any information as
to my questions would be wonderful!

Also, please CC me on responses since I'm on the digest!  Thank you in
advance!

Martin


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to