Page 1 of 1
Getting visitors IP address in php?
Posted: Wed Aug 14, 2002 8:45 pm
by lc
is there a way to get the visitor's (the person requesting a page) IP number as a variable in PHP?
Posted: Wed Aug 14, 2002 9:02 pm
by protokol
$ip = $_SERVER['REMOTE_ADDR']; // grabs IP address
$hostname = gethostbyaddr($ip); // resolves hostname from IP address
Posted: Wed Aug 14, 2002 9:08 pm
by lc
Coolness.. I'm going to try it out right now... had a problem with someone using 1 of my scripts.
He had someone entering 200 messages a day in a gb I wrote... Now I can rewrite it to store the IP address along with everything... and block it after it left it's 1 allowed message.
Thx.. you's a big help
Posted: Wed Aug 14, 2002 11:50 pm
by hob_goblin
$ip = getenv('REMOTE_ADDR');
works, as well.