Northern Flame Posted March 8, 2008 Share Posted March 8, 2008 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 More sharing options...
Daniel0 Posted March 8, 2008 Share Posted March 8, 2008 You can use GeoIP. Link to comment https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487117 Share on other sites More sharing options...
Northern Flame Posted March 8, 2008 Author Share Posted March 8, 2008 alright thanks, im looking at the link right now Link to comment https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487119 Share on other sites More sharing options...
Northern Flame Posted March 8, 2008 Author Share Posted March 8, 2008 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 More sharing options...
Daniel0 Posted March 8, 2008 Share Posted March 8, 2008 That won't work. My current user agent is Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3, but I'm in Denmark, which is far from USA. Link to comment https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487132 Share on other sites More sharing options...
Northern Flame Posted March 8, 2008 Author Share Posted March 8, 2008 oh alright, well thanks for the help, ill look into another way of doing this. Link to comment https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487133 Share on other sites More sharing options...
peranha Posted March 8, 2008 Share Posted March 8, 2008 Here is one you can look at http://software77.net/geoip-software.htm Link to comment https://forums.phpfreaks.com/topic/95100-ip-address-to-country/#findComment-487138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.