Hi all...I am new here and fairly new at PHP.
I have a select box that is populated with the contents of a text file. (it is a list of countries)
The problem is that when the page with all the form data is sent to my validate php script, the first entry in the select box is always chosen, even if I haven't 'clicked' to select an entry....so the first country in the text file (United States) automatically gets selected.
I want to display a message that states "please go back and select a country" when the user hasn't explicitly clicked on what selection they want, rather than have it just default to the first item in the list.
I tried putting a blank line in the first line of the text file and checking for that but that doesn't seem to work either.
So, the first way I tried it (with US being the very first entry in the text file) is like this:
if(!$_POST['country'])
{
echo "You didn't select a country. Please press the Back Button and try again";
that doesn't work because US is selected by default.
After putting a blank line (just 1 enter keystroke - no spaces) in the text file I tried it this way:
if($_POST['country'] == "" )
{
echo "You didn't select a country. Please press the Back Button and try again";
Neither way is working. Can anybody help me with this?
thanks