User Location Script Containing World Database

by Hiroshi on November 18, 2015

in database, MySQL, Scripts

Being a website developer, I always wanted a control in which I can find visitor’s country name, country code, region or state name and city name. I wanted to redirect users based on their country and region. Now we have a script that let’s your visitor choose or set location so that he can perform certain actions based on his location. A clear use of such script is seen in local classified websites where visitor can post ad for his own country, state or even city. You can also show content of website that is dependent on visitor’s location. You can serve different pages to visitors coming from the United States and different for users coming from Canada. Very useful piece of script that is light weight, based on mySQL and PHP, contains full world database and easy to implement in any PHP based website. Database associated with it is really light weight that is easy to import / export for phpMyAdmin.


PHP mySQL User Location allows you to integrate countries, states, regions and cities of the world into your website. Its a chained select user location selection functionality that enable users to perform location based actions.

PHP mySQL User Location is a PHP script that lets your website’s visitor choose or set country, region and city by using your website’s mySQL database. Countries, regions (states, provinces, territory) and cities database associated with this app is light weight to facilitate import / export for localhost or online database server. It also contains country codes, region codes, longitudes and latitudes. Database has been broken down to small parts that can be imported separately from multiple files into phpMyAdmin. After country, region and city is set on a website, website can perform location based actions. You can redirect website users to specific sections based on their location. For example, if you have got a classified (online advertisement) website, you can enable users to store and view local ads from their own location. Enable your website to respect user’s location.

It also includes a method to auto detect and store ‘visitor’s country’ and ‘country code’.


  • 246 Countries, 4151 Regions (states, provinces, territories), 103818 cities with Country Codes, Region Codes, Longitudes and Latitudes
  • mySQL database of total 9.41 MB in size, broken down in 8 *.sql files for easy import/export actions. Import countries, regions and cities in database from separate sql files.
  • Comes with admin section to add / edit countries, regions (states, provinces) and cities from database
  • Bonus PHP script included (auto detect and set user’s country name and country code)
  • Three level Chained Select Menu Control
  • Country flags included
  • jQuery / Twitter Bootstrap / FontAwesome support
  • Fully supported PHP, mySQL, jQuery based webapp
  • Well written documentation
  • Well commented, clean code
  • Easy to understand and use

Live Demo
Download PHP mySQL User Location Script

Related Posts

Previous post: