I have a html form with an option select for choosing a country name see sample code bellow
I'm wondering how to validate this part of the form in PHP using filter input
filter_input(INPUT_POST, "Country", FILTER_VALIDATE_INT);
Will detect if no country has been selected because the value is 1
how would I validate a proper 3 figure country code
Is regex the best way or test for string length?
<div >
<select name="Country" >
<option selected value=1>Please select</option>
<option value="BRA">Brazil</option>
<option value="NZL">New Zealand</option>
<option value="SWZ">Switzerland</option>
</select>
</div>
Open in new window
if (is_numeric($POST["Country
echo "No country selected";
} else {
$country = array("brazil", "new land", "xxxx", "yyy");
if (in_array($_POST["Country"
echo "Got it";
}
else
{
echo "no";
}
}