Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Photo
- - - - -

User Ip And City Tracing In Php


3 replies to this topic

#1 arunkumarhg

arunkumarhg

    Advanced Member

  • Members
  • 135 posts
  • Location:Bangalore, India
  • Interests:Programming,Designing

Posted 21 December 2004 - 12:41 PM

Hi,

Am in damm need of tracing the Users IP and City hwre they are from with PHP,
Any help please.......


Thanks in Advance
Arunkumar.H.G

#2 jipman

jipman

    Super Member

  • Members
  • 733 posts

Posted 21 December 2004 - 03:44 PM

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.

#3 cryptwizard

cryptwizard

    Member - Active Contributor

  • Members
  • 77 posts

Posted 21 December 2004 - 08:47 PM

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:
http://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.

#4 arunkumarhg

arunkumarhg

    Advanced Member

  • Members
  • 135 posts
  • Location:Bangalore, India
  • Interests:Programming,Designing

Posted 22 December 2004 - 11:22 AM

Thanks for your reply,
recently i gone through the http://www.ip2location.com/ there they will display even city also, how it is done. Any links resources please....

Regards
Arunkumar.H.G



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users