Problem
I want to provide users of my web with city selection when they are registering to this web app. I have to be sure, that the address is correct, because I am sending them regular mail consequently in order to verify their address. And nonsense or misspelled city names can cause trouble for me.
Current state
Up to now, I always used a database table with names of all cities in my country. My country has about 600 cities, so it wasn't problem to populate table manually from wikipedia. However, recently I am planning to allow registration from other countries including Germany and USA and that should be problem.
Question
I would like to ask you how city selection/validation could be solved professionally?
Mercury, Nevada is situated within the Nevada Test Site, the primary testing location of American nuclear devices from 1951 to 1992, currently called Nevada National Security Site, and is currently closed as part of this site. Oak Ridge, Tennessee was a closed city during the Manhattan Project.
A closed city or closed town is a settlement with travel and residency restrictions in the Soviet Union, some of its successor countries, or the United States.
What is this? Today, most of the formerly closed Russian cities are open to the public but there are a few of them which are still hidden by the authorities. It's estimated that today, there are around 40 closed Russian cities and more than 1.5 million people live here.
I don't think its practical to keep a database of city/states because you will then have another problem of keeping this updated and making sure you store all variations of a city name as well.
Its better to use a third party web service. The United States Postal Service (USPS) provides a web service you can use. You can send this any address, and it will return to you a cleaned/verified version (if the address is valid), or an error message.
Similar services can be found for other countries or by using the APIs of multi-national courier companies like DHL or FedEx.
However, as you are planning to ship goods - why not go with a service like Easypost? Not only do they provide a comprehensive api, but they will also validate addresses and even calculate shipping rates (should you wish).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With