How can I get the user's IP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GregArtemides
Forum Newbie
Posts: 5
Joined: Fri Jun 13, 2003 7:03 pm

How can I get the user's IP

Post by GregArtemides »

I'm looking for a way to get the ip address of users logging into my site, for security purposes. Is there a function in PHP that would do this? Does anyone have a script that would do this? I basically want to make sure that I know where a user is registering from, as a way of monitoring anauthorized users trying to sneek in. Any ideas? :?:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

take a look at the members of $_SERVER at http://php.net/reserved.variables
Last edited by volka on Fri Jun 13, 2003 7:11 pm, edited 1 time in total.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

See the bottom of this thread:

viewtopic.php?t=9560

Regards,

Volka: Jinx :)
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

If you need the IP address for security purposes I also recomend reading about HTTP_X_FORWARDED_FOR - it's a reserved variable for you real IP when someone is connecting through a proxy server. Then the REMOTE_ADDR will have the proxy's IP and HTTP_X_.... will have the "real" user. Read the PHP manual page which volka gave you and especially the user notes at the bottom.
Post Reply