Learn how to get country name from ip address with php - the php function takes up ip address as parameter, call for the geoPlugin api for user's location details and returns the country name, city, currency, latitude, longitude etc. as json.
Read this post on kodingmadesimple.com