Hi,
How can I get IP address of a client that logged in into my site?
thanks,
webtekie
client IP address
Moderators: egami, macek, gesf
$ip = $_SERVER['REMOTE_ADDR'];
Andrew
Andrew
-
- New php-forum User
- Posts: 13
- Joined: Mon Mar 17, 2003 6:38 am
You can use this code: :arrow:
$file="Path To Log File"; #/home/site.com/...
$fp=fopen($file,'a') or die("Couldn't Log!");
fputs($fp,"$REMOTE_ADDR\n");
fclose($fp);
It will open the log file and will add the visitor IP address to it. :P
If you'll do what Andrew suggested you will only see your own IP address. :roll:
$file="Path To Log File"; #/home/site.com/...
$fp=fopen($file,'a') or die("Couldn't Log!");
fputs($fp,"$REMOTE_ADDR\n");
fclose($fp);
It will open the log file and will add the visitor IP address to it. :P
If you'll do what Andrew suggested you will only see your own IP address. :roll:
really? I was under the impression that displayed the IP of that PC... it's used in a browsing counter that I use, and it stores the IP of that clients PC every time.
Andrew
Andrew
sleepingdanny wrote:You can use this code: :arrow:
$file="Path To Log File"; #/home/site.com/...
$fp=fopen($file,'a') or die("Couldn't Log!");
fputs($fp,"$REMOTE_ADDR\n");
fclose($fp);
It will open the log file and will add the visitor IP address to it. :P
If you'll do what Andrew suggested you will only see your own IP address. :roll:
$REMOTE_ADDR and $_SERVER['REMOTE_ADDR'] are the same thing. Only thing is $REMOTE_ADDR will only work if register_globals is turned on which is the not so smart way to run a server.