Jump to content

IP Address to Country?


Northern Flame

Recommended Posts

Is there a way to match the users IP address to their country?

or any other way to tell which country the user is in?

I've been looking at the $_SERVER variables but I can't seem to

find anything on getting the country. Any help will be greatly

appreciated!

 

P.S. I want to get the users country so I can display the websites

content in the language of that country.

Link to comment
https://forums.phpfreaks.com/topic/95100-ip-address-to-country/
Share on other sites

oh well you have to pay for that

and I would prefer to make it myself  :)

 

 

would this work?

 

$_SERVER['HTTP_USER_AGENT']

 

I just tried it and I got this as a result:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12

 

so I guess I can just take the en-US part to determine their location and language.

but would that work all the time or is it the same string for this browser no matter where

your location is?

 

-----------------------------------------------------------------------------

 

oh wait never mind, i just tried this on IE and i get this:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.2.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

and form that I cant see anyway to determine their location or language

 

Link to comment
https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487127
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.