Yesterday, I asked how to make the form somehow user friendly by keeping the user's selection in the drop down menu if he has to go back to edit a mistake without having to reselect his country. An expert told me how to solve it & it worked fine BUT it looks like it has a side effect. First I will provide the codes then explain what happens. <p> Country/region: <select name="Country" > <?php if(isset($_REQUEST['Country'])) { ?> <option value="<?php echo $_REQUEST['Country'] ?>" selected="selected"><?php echo $_REQUEST['Country']; ?></option><?php } ?> <option value="CountryA">CountryA</option> <option value="CountryB">CountryB</option> <option value="CountryC">CountryC</option></select></p> Code (markup): CASE "1" You go to the registration page. You find that CountryA is selected for you...!You can change it but it should not look like that..! <p> Country/region: <select name="Country" > <?php if(isset($_REQUEST['Country'])) { ?> <option value="<?php echo $_REQUEST['Country'] ?>" selected="selected"><?php echo $_REQUEST['Country']; ?></option><?php } ?> <option >Select Country</option> <option value="CountryA">CountryA</option> <option value="CountryB">CountryB</option> <option value="CountryC">CountryC</option></select></p> Code (markup): CASE "2" I had the idea of adding an option called "Select Country" before Country A. It works fine as when you register you find Select Country & no countries are selected for you BUT if you make an error & you go back to correct it you find "Select Country" as an option to select for your country field. I have attached an image of CASE "2" in order to make it clear. The question is how to make a normal drop down menu without losing the feature of remembering the user selection ?!
<p> Country/region: <select name="Country" > <?php if(isset($_REQUEST['Country']) && $_REQUEST['Country'] != "Select Country") { ?> <option value="<?php echo $_REQUEST['Country'] ?>" selected="selected"><?php echo $_REQUEST['Country']; ?></option><?php } ?> <option >Select Country</option> <option value="CountryA">CountryA</option> <option value="CountryB">CountryB</option> <option value="CountryC">CountryC</option></select></p> PHP: