|
What I would do is create a has out of the country names and generate a dropdown menu based on that.
For example, say we have a small hash
$countries array(0 => "United States", 1 => "United Kingdom", 2 => "Algeria")
then make a foreach loop to do the select box, with the number being the value and the country what it displays. So like
<option value="0">United States</option> except the loop will generate it from the hash.
So then, it sets the post variable to the form action script, so you'll get a 1, a 2, or a 3. You can validate it by saying
$country = $_POST[country]
$country = $countries[$country]
That way not only will it validate for text, but it will validate to make sure that it's a real country from a list that you have pre-defined. You can also easily do this with a SQL database instead of a hash.
|