title: HTML option form with php
body: <p>Currently I'm a bit stuck on PHP and HTML, my teacher has asked me to change my code into a drop down selection, </p>
  
  <p>So far i have this</p>
  
  <pre><code>$html .='&lt;option value="Argentina" &lt;?php if($_POST['YourCountry']=="Argentina") echo "selected=selected"; ?&gt;&gt;Argentina&lt;/option&gt;';
  </code></pre>
  
  <p>I'm not sure why it isn't working. I'm trying to get it so that when a person selects the option in the box it will be the value set into the insert query. This was my input one which my teacher ask me to change into a option one i have no idea how the option one</p>
  
  <pre><code>$html .='&lt;input type="text" name="userCountry" id="userCountry" value="'.htmlentities(stripcslashes($_POST['userCountry'])).'" /&gt;&lt;br/&gt;'."\n";
  </code></pre>
  
  <p>Full code ===================================></p>
  
  <pre><code>&lt;?php
  
  class HomeView extends View {
      protected function displayContent() {
          $html .= '&lt;div id="pageinfo"&gt;'."\n";
          $html .= '&lt;h2&gt;'.$this -&gt; pageInfo['pageHeading'].'&lt;/h2&gt;'."\n";
          $html .= '&lt;/div&gt;'."\n";
              if($_POST['register'] == "Submit") {
              //validate the form
  
  
  
              $vresult = $this -&gt; model -&gt; validateRegisterUser();
  
  
              //Check ALL okay
                   if ($vresult['ok'] == true) {
                  //Call database
  
  
                              if ($this -&gt; model -&gt; register()) {
                                  $htmt .='&lt;div id="space"&gt;'."\n";
                                  $html .='&lt;div id="userreg"&gt;'."\n";
                                  $html .='&lt;p&gt; User registered successfully&lt;p&gt;'."\n";
                                  $html .= '&lt;p&gt;Please login '.$_POST['userName'].'&lt;/p&gt;'."\n";
                                  $html .='&lt;img src ="optimized/images/joined.jpg" alt="welcome new member"/&gt;'."\n";
  
                                  $html .='&lt;/div&gt;'."\n";
                                  $html .='&lt;/div&gt;'."\n";
                                      } else {
  
                                  $html .='&lt;div id="space"&gt;'."\n";
                                  $html .='&lt;img src ="optimized/images/failed.jpg" alt="failed to create new member"/&gt;'."\n";
                                  $html .= '&lt;p&gt; User creation failed. Please try again &lt;p&gt;'."\n";
                                  $html .='&lt;/div&gt;'."\n";
                              }        
                          return $html;
                  }   
              }
              $html .='&lt;div id="register"&gt;'."\n";
  
                  $html .='&lt;img src="optimized/images/rg.jpg" alt="registerimage"/&gt;'."\n";
                  $html .='&lt;form method="post" action="'.$_SERVER['REQUEST_URI'].'" onSubmit="return confirm("Are you sure?");"&gt;'."\n";
                      $html .='&lt;fieldset&gt;'."\n";
                          $html .='&lt;legend&gt;'.'New Members Form'.'&lt;/legend&gt;'."\n";
                          $html .='&lt;label for="username"&gt;Username: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userName" id="userName" value="'.htmlentities(stripcslashes($_POST['userName'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userNameMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userFName"&gt;Firstname: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userFName" id="userFName1" value="'.htmlentities(stripcslashes($_POST['userFName'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userFNameMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userLName"&gt;Surname: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userLName" id="userLName" value="'.htmlentities(stripcslashes($_POST['userLName'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userLNameMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userEmail"&gt;Email: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userEmail" id="userEmail" value="'.htmlentities(stripcslashes($_POST['userEmail'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userEmailMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userPassword"&gt;Password: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="password" name="userPassword" id="userPassword1" value="'.htmlentities(stripcslashes($_POST['userPassword'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userPasswordMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userPassword"&gt;Re-Enter Password: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="password" name="userPassword2" id="userPassword2" value="'.htmlentities(stripcslashes($_POST['userPassword2'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userPrematchPass'].'&lt;/div&gt;'."\n";
  
  
  
                          $html .='&lt;label for="userPhone"&gt;Telephone: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userPhone" id="userPhone" value="'.htmlentities(stripcslashes($_POST['userPhone'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userPhoneMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userAddress"&gt;Address: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userAddress" id="userAddress" value="'.htmlentities(stripcslashes($_POST['userAddress'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userAddressMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userCity"&gt;City: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userCity" id="userCity" value="'.htmlentities(stripcslashes($_POST['userCity'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userCityMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userCountry"&gt;NewZealand: &lt;/label&gt;&lt;br/&gt;'."\n";
                           $html .='&lt;select name="Location"&gt;'."\n";
  $html .='&lt;option value=""&gt;&lt;/option&gt;'."\n";
  $html .='&lt;option value="North-Island"&gt;North-Island&lt;/option&gt;';
  $html .='&lt;option value="South-Island"&gt;South-Island&lt;/option&gt;';
  $html .='&lt;option value="Other"&gt;Other&lt;/option&gt;';
   $html .='&lt;option value="Argentina" &lt;?php if($_POST['YourCountry']=="Argentina") echo "selected=selected"; ?&gt;&gt;Argentina&lt;/option&gt;';
  
  
  
  
  
  
  
  
                          $html .='&lt;input type="text" name="userCountry" id="userCountry" value="'.htmlentities(stripcslashes($_POST['userCountry'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userCountryMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;label for="userPostcode"&gt;Post Code: &lt;/label&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;input type="text" name="userPostcode" id="userPostcode" value="'.htmlentities(stripcslashes($_POST['userPostcode'])).'" /&gt;&lt;br/&gt;'."\n";
                          $html .='&lt;div class="error"&gt;'.$vresult['userPostcodeMsg'].'&lt;/div&gt;'."\n";
                          $html .='&lt;input type="submit" name="register" value="Submit" id="submit"/&gt;'."\n";
                      $html .='&lt;/fieldset&gt;'."\n";
                  $html .='&lt;/form&gt;'."\n";
              $html .=' &lt;/div&gt;'."\n";
          return $html;
      }
  }
  
  ?&gt;
  </code></pre>