Jump to content
xisto Community
Sign in to follow this  
arunkumarhg

User Ip And City Tracing In Php User IP and City Tracing in PHP

Recommended Posts

IP is easy if you mean the client that connects to your server has to be logged.$adress = $_SERVER['REMOTE_ADDR'];insert that line and the variable $adress will be the IP you need.But city is not possible i think, because the IP only refers to the company that has registered the subnet ( first 3 digits of you ip). So you can only find out who someones ISP is. And in wich country someone is. All you need to do is a whois to the ip you just got.

Share this post


Link to post
Share on other sites

To get a host name (something like xxx.70.233.220.exetel.com.au) run the IP address through gethostbyaddr($ip).

Like jipman said the IP address is accessible through $_SERVER['REMOTE_ADDR'].

 

To get their contury, there's an API here:

https://sourceforge.net/projects/geoip/

I never used it myself, but I've seen it in use on mySQL.com and it works for me.

It has APIs for a wide variety of languages.

 

Hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.