Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

client IP address

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

client IP address

Postby webtekie » Wed Apr 16, 2003 6:03 am

Hi,

How can I get IP address of a client that logged in into my site?

thanks,
webtekie
webtekie
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Apr 10, 2003 10:33 am
Location: brooklyn, ny

Postby bezmond » Wed Apr 16, 2003 6:22 am

$ip = $_SERVER['REMOTE_ADDR'];

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby sleepingdanny » Thu Apr 17, 2003 1:40 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:
sleepingdanny
New php-forum User
New php-forum User
 
Posts: 13
Joined: Mon Mar 17, 2003 6:38 am

Postby bezmond » Thu Apr 17, 2003 2:05 am

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
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby Redcircle » Thu Apr 17, 2003 11:16 am

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.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.