title: How to keep the dropdown menu selected value after form is submitted?
body: <p>I am creating a very simple form with a dropdown menu and a text filed.
  It shows the errors if the form has empty field during the submission.</p>
  
  <p>I want to show the filled values after the form submission if there is any error.
  It works on text field as I expected.
  Ex: If fill the <code>name</code> and submit the form without filling the <code>title</code> dropdown menu, it showing the name I typed on the filed during the the error is appeared.</p>
  
  <p>But how can I do that for dropdown menu also?
  Ex: If I select the <code>title</code> drop down menu and submit the form without filling <code>name</code> field, it should show the selected <code>title</code> dropdown value during the the error is appeared.</p>
  
  <p>how can I do that?
  here is my code and it's a wordpress site:</p>
  
  <pre><code>&lt;?PHP
  $errors = array();
      if($_POST["submit"]) {
          $name_title = $_POST["name_title"];
          $sender = $_POST["sendername"];
  
          //Check the name title that it is selected or none.
                  if($name_title === none){
                      //if selected is none, add error to $errors array.        
                      $errors['name_title'] = "Please select the title of your name!";
                  }
  
          if(empty($sender)){
              //Blank string, add error to $errors array.        
              $errors['sendername'] = "Please enter your name!";
          }
  
          // sending form
          if(empty($errors)){
              $mail_sent = wp_mail( $to, $subject, $mailBody, $headers ); 
          }       
  
      }
      if ($mail_sent) {
  ?&gt;
  
  &lt;h1 style="color: #007f00;"&gt;Request sent.&lt;/h1&gt;
  
  &lt;?php 
  } else {
  ?&gt;
  
  &lt;form id="" name="" action="&lt;?php echo get_permalink(); ?&gt;" method="post"&gt;
      &lt;div class="label-input-wrapper"&gt;
          &lt;div class="form-label"&gt;Title&lt;/div&gt;
          &lt;div class="form-input"&gt;
              &lt;select name="name_title" class="name-title-input"&gt;                 
                  &lt;option value="none" selected="selected"&gt;Select Title&lt;/option&gt;
                  &lt;option value="Mr"&gt;Mr&lt;/option&gt;
                  &lt;option value="Mrs"&gt;Mrs&lt;/option&gt;
                  &lt;option value="Miss"&gt;Miss&lt;/option&gt;
                  &lt;option value="4"&gt;Ms&lt;/option&gt;                   
              &lt;/select&gt;
              &lt;div class="error-msg"&gt;
                  &lt;?php if(isset($errors['name_title'])) { echo '&lt;span style="color: red"&gt;'.$errors['name_title'].'&lt;/span&gt;'; } ?&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
      &lt;/div&gt;  
  
      &lt;div class="label-input-wrapper"&gt;
          &lt;div class="form-label"&gt;Name&lt;/div&gt;
          &lt;div class="form-input"&gt;
              &lt;input type="text" name="sendername" value="&lt;?PHP if(!empty($errors)) { echo $sender;} ?&gt;" /&gt;
              &lt;div class="error-msg"&gt;
                  &lt;?php if(isset($errors['sendername'])) { echo '&lt;span style="color: red"&gt;'.$errors['sendername'].'&lt;/span&gt;'; } ?&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;input type="submit" value="Submit" name="submit"&gt;
  &lt;/form&gt;
  
  &lt;?php
  }  
  ?&gt;
  </code></pre>