faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

120 of 174 people (69%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I capture I.P address of clients who are browsing the pages same as mine?

Mar 6th, 2000 19:37
Jeff Eidsness, Shachi, unknown unknown,


There is a nifty variable in PHP called $REMOTE_ADDR which contains the 
ip address of the person visiting your site. You can log these values 
to a file or some other external program as you need to. it will NOT 
tell you how long they stayed at any one oage or what page they are 
currently viewing, just when their browser asked the server for the 
page. Here is a simple(?) way to do it...

<?
$logged_string = "$REMOTE_ADDR|" . date("j M Y g:i a");
$file = fopen("userIP.log", "a");
fputs($file, $logged_string, strlen($logged_string));
fclose($file);
?>

  easy as tacos!