Discussion:
Registration with Country---State/Region---City
(too old to reply)
nameless
2009-09-24 09:42:05 UTC
Permalink
When a users wants to register on my site, he must select Country,
State/Region and City.

How could I do that ?
I have bought Ip2location but it's incomplete for some cities.


Ip2Location is like this ( latitude and longitude is unnecessary ):

"UNITED STATES","MASSACHUSETTS","BEVERLY","42.5685","-70.8619"
"UNITED STATES","CONNECTICUT","FAIRFIELD","41.1862","-73.2613"
"UNITED STATES","NEW JERSEY","LEBANON","40.6482","-74.817"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"SPAIN","CASTILLA Y LEON","SALAMANCA","40.967","-5.65"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"


If there is an alternative solution tell me ( also without database
because ip2location database is 500MB !! ).
Thank you !!
Gordon Burditt
2009-09-25 01:28:58 UTC
Permalink
Post by nameless
When a users wants to register on my site, he must select Country,
State/Region and City.
How could I do that ?
I've seen some sites do this with HTML SELECT combined with AJAX
and Javascript. Put the lists in the order Country, State/Region,
and City. The Country list is fully populated. The others have a
dummy entry like "Select State/Region". When the user selects one,
it populates the State/Region list with the values for the selected
country (with an AJAX query for all states/regions with the specified
Country). When the user selects a State/Region, it populates the
City list (with an AJAX query for all Cities with the specified
Country and State/Region).

You do need some kind of database here, at least to list all the
states/regions in a country and all the cities in a state/region.
Putting the complete list in Javascript takes way too long to
download (You said it was 500MB, and that will probably run some
browsers out of memory trying to run it).

If the lists are incomplete, allow a user to select "User Supplied"
as a value, and when he selects it, make an input field appear to
let him type something in.

Obviously, you don't have any idea where an unknown country is
(besides it probably being on Earth), but you might later be able
to manually fix your list. If an estimate is better than nothing,
you *DO* have some idea where an unknown state/region is: try the
center of the country. You *DO* have an idea where an unknown city
is: try the center of the state/region.

Don't send the lat/long numbers to the browser (at least until
you're down to one set of them). Your lists are long enough already.
Look them up in a database once you've got Country, State/Region,
and City.

Don't *automatically* fix your list. Some joker is bound to try
to add the State of Inebriation and other things less suitable for
children to read.
Post by nameless
I have bought Ip2location but it's incomplete for some cities.
Loading...