lonelym 0 Report post Posted August 15, 2007 Is there a function in PHP where I could get the user's IP address or something? I require this function because I plan on restricting a '1 account per IP address' rule on my site. Thanks. Share this post Link to post Share on other sites
Sten 0 Report post Posted August 15, 2007 yesand aparantly its easyi dont no how to but yeah its like a basic php function or something. Share this post Link to post Share on other sites
dserban 0 Report post Posted August 15, 2007 It depends on whether or not you want proxy detection.Use PHP's getenv() function to read the value of the environment.Your choices are:- Without proxy detection => REMOTE_ADDR - get the remote client's IP address- With proxy detection => HTTP_X_FORWARDED_FOR - get IP address of proxy server Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 15, 2007 if (getenv("HTTP_CLIENT_IP")){ $ip = getenv("HTTP_CLIENT_IP");}else if(getenv("REMOTE_ADDR")){ $ip = getenv("REMOTE_ADDR");}else if(getenv("HTTP_X_FORWARDED_FOR")){ $ip = getenv("HTTP_X_FORWARDED_FOR");}$ip will be the IP address Share this post Link to post Share on other sites
lonelym 0 Report post Posted August 15, 2007 Thanks for letting me know. I'll look it up. If anyone could help out, it would be appreciated. Share this post Link to post Share on other sites
lonelym 0 Report post Posted August 15, 2007 Thank you very much! It helped me a lot. Share this post Link to post Share on other sites
dserban 0 Report post Posted August 15, 2007 I plan on restricting a '1 account per IP address' rule on my site.Hmmmmm, good luck with that if people's IP addresses are going to be dynamically allocated by their ISP's every time they establish a connection.I suggest you learn more about how ISP's work - and do some reading on DHCP (Dynamic Host Configuration Protocol). Bottom line, it's not as easy as you may think it is. Share this post Link to post Share on other sites
lonelym 0 Report post Posted August 16, 2007 Oh. I guess it is hard. I'll try to find more things about it. Share this post Link to post Share on other sites