title: How to get option in drop down menu back to "Please Select" option?
body: <pre><code>&lt;?php
              // required variables (make them explciit no need for foreach loop)
  
              $getyear       = (isset($_POST['year'])) ? $_POST['year'] : '';
              $getpass       = (isset($_POST['studentpass'])) ? $_POST['studentpass'] : '';
              $getretypepass = (isset($_POST['retypepass'])) ? $_POST['retypepass'] : '';
              $errormsg      = (isset($errormsg)) ? $errormsg : '';
  
  $validSubmission = (isset($_POST['registerbtn']) &amp;&amp; isset($getyear) &amp;&amp; isset($getpass) &amp;&amp; isset($getretypepass));
  
              $min_year = 1;
              $max_year = 10;
              $years    = range($min_year, $max_year); // returns array with numeric values of 1900 - 2012
              $yearHTML = '';
              $yearHTML .= '&lt;select name="year" id="yearDrop"&gt;' . PHP_EOL;
              $yearHTML .= '&lt;option value=""&gt;Please Select&lt;/option&gt;' . PHP_EOL;
      foreach ($years as $year) {
          if ($validSubmission &amp;&amp; $year == $getyear) {
              $yearHTML .= "&lt;option value='" . $year . "' selected='selected'&gt;$year&lt;/option&gt;" . PHP_EOL;
          } else {
              $yearHTML .= "&lt;option value='" . $year . "'&gt;$year&lt;/option&gt;" . PHP_EOL;
          }
      }
  
              $yearHTML .= '&lt;/select&gt;';
  
  
              if ((isset($_POST['registerbtn']))) {
                  if (in_array($_POST['year'], $years) === true) {
                      $getyear = (int) $_POST['year'];
                  }
                  $getpass       = $_POST['studentpass'];
                  $getretypepass = $_POST['retypepass'];
  
  
                  if ($getyear) {
                      if ($getpass) {
                          if (strlen($getpass) &lt;= 5) {
                              $errormsg = "The Password must be a minimum of 6 characters or more";
                          } else {
                              if ($getretypepass) {
                                  if ($getpass === $getretypepass) {
                                      //perform 2 queries, one query contains $aliasnumrows and other contains $numrows
  
                                      if ($aliasnumrows == 0) {
                                          if ($numrows == 0) {
                                              //perform query which contains $numrows
  
  
                                              if ($numrows == 1) {
                                                  $errormsg = "&lt;span style='color: green'&gt;Student has been Registered&lt;/span&gt;";
  
                                                  $getyear = "";
  
  
                                              } else {
                                                  $errormsg = "An error has occured, Student has not been Registered";
  
                                              }
  
                                          }
  
                                          else {
                                              $errormsg = "There is already a Student with that Username";
                                          }
                                      }
  
                                      else {
                                          $errormsg = "There is already a Student with that Alias";
                                      }
                                  }
  
                                  else {
                                      $errormsg = "Your Passwords did not match";
                                  }
                              }
  
                              else {
                                  $errormsg = "You must retype your Password to Register";
                              }
                          }
                      } else {
                          $errormsg = "You must enter in a Password to Register";
                      }
  
                  }
  
              else{
          $errormsg = "You must enter in Student's current Academic Year to Register";
          }
  
          }
  
      $form = "
      &lt;form action='" . htmlentities($_SERVER["PHP_SELF"]) . "' method='post'&gt;
        &lt;table&gt;
        &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td id='errormsg'&gt;$errormsg&lt;/td&gt;
      &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td&gt;Year:&lt;/td&gt;
        &lt;td&gt;{$yearHTML}&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td&gt;Password:&lt;/td&gt;
        &lt;td&gt;&lt;input type='password' name='studentpass' value='' /&gt;&lt;/td&gt;  
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td&gt;Retype Password:&lt;/td&gt;
        &lt;td&gt;&lt;input type='password' name='retypepass' value='' /&gt;&lt;/td&gt;  
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input type='submit' value='Register' name='registerbtn' /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;/table&gt;
        &lt;/form&gt;";
  
        echo $form;
  </code></pre>
  
  <p>In the code above, I have managed to keep a drop down option stay selected after the form hs been submitted. But what I want to do is that if the success message appear after form is submitted:</p>
  
  <pre><code>if ($numrows == 1) {
  $errormsg = "&lt;span style='color: green'&gt;Student has been Registered&lt;/span&gt;";
  
   $getyear = "";
  
  
  }
  </code></pre>
  
  <p>Then I want the drop down menu to go back the "Please Select" option. How can this be achieved?</p>