title: How do i keep the selected value in the dropdown menu when the form is submitted?
body: <p>How do i keep the selected value in <code>select name="betalingsmethode" class="dropdown"</code> after the form is submitted. What happens now is when I submit the form the drop-down refreshes and shows <code>Visa</code> again. but I want to keep the selected value in there, the one the user selected.</p>
  
  <p>I tried the same as I did with the checkboxes: </p>
  
  <pre><code>?php if(isset($_POST['visa'])) echo "selected='selected'"; ?
  </code></pre>
  
  <p>But it doesn't work.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="nl"&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type"
                content="text/html;
                charset=UTF-8" /&gt;
          &lt;title&gt;Mijn Muziek&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;!-- shoppingcart starts here --&gt;
          &lt;table border=0 cellpadding=0 cellspacing=0 width=100%&gt;
              &lt;form name="order"
                    action="lab07.php"
                    method="POST"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;img src="images/evora.jpg" width="100px" alt="X" /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          Cesaria Evora "Em Um Concerto" Track:10 Prijs: 9.99
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;input type="hidden" name="albumcode[0]"
                                 value="001" /&gt;
                          &lt;input type="hidden" name="artiest[0]"
                                 value="Cesaria Evora" /&gt;
                          &lt;input type="hidden" name="titel[0]"
                                 value="Em Um Concerto" /&gt;
                          &lt;input type="hidden" name="tracks[0]"
                                 value="10" /&gt;
                          &lt;input type="hidden" name="prijs[0]"
                                 value="9.99" /&gt;
                          &lt;input type="hidden" name="genre[0]"
                                 value="World" /&gt;
  
                          Aantal: &lt;input type="text" size=2 maxlength=3
                                         name="aantal" value="&lt;?php echo(isset($_POST['aantal'])) ? $_POST['aantal'] : '0'; ?&gt;"
                                         style="background-color:#f8ce6c" /&gt;
  
                          &lt;hr /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr&gt;
                      &lt;td&gt;Korting:&lt;br /&gt;
                          &lt;input type="checkbox" name="student" id="student"
                                 value="15" &lt;?php
                                 if (isset($_POST['student']))
                                     echo
                                     "checked='checked'";
                                 ?&gt; /&gt;
                          Student 15%&lt;br /&gt;
                          &lt;input type="checkbox" name="senior" id="senior"
                                 value="10" &lt;?php
                                 if (isset($_POST['senior']))
                                     echo
                                     "checked='checked'";
                                 ?&gt; /&gt;
                          Senior 10%&lt;br /&gt;
                          &lt;input type="checkbox" name="klant" id="klant"
                                 value="5" &lt;?php
                                 if (isset($_POST['klant']))
                                     echo
                                     "checked='checked'";
                                 ?&gt; /&gt;
                          Klant 5%&lt;br /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;td&gt; Selecteer een betalingswijze: &lt;/td&gt;
  
  
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;select name="betalingsmethode" class="dropdown"&gt;
                              &lt;option value="visa"       name="visa"&gt;Visa             &lt;?php if (isset($_POST['visa'])) echo "selected='selected'"; ?&gt;&lt;/option&gt;
                              &lt;option value="mastercard" name="mastercard"&gt;Mastercard &lt;?php if (isset($_POST['mastercard'])) echo "selected='selected'"; ?&gt;&lt;/option&gt;
                              &lt;option value="paypal"     name="paypal"&gt;PayPal         &lt;?php if (isset($_POST['paypal'])) echo "selected='selected'"; ?&gt;&lt;/option&gt;
                              &lt;option value="ideal"      name="ideal"&gt;Ideal           &lt;?php if (isset($_POST['ideal'])) echo "selected='selected'"; ?&gt;&lt;/option&gt;
                          &lt;/select&gt;
                          &lt;input type="submit" width="300px" name="submit"
                                 value="      Bestellen      " /&gt;
                          &lt;hr /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/form&gt;
          &lt;/table&gt;
          &lt;!-- Shoppingcart ends here--&gt;
          &lt;?php
          echo "Aantal is: ";
          if (isset($_POST['aantal'])) {
              echo $_POST['aantal'];
          }
  
          $korting = 0;
          if (isset($_POST["student"]))
              $korting = $korting + 15;
          if (isset($_POST["senior"]))
              $korting = $korting + 10;
          if (isset($_POST["klant"]))
              $korting = $korting + 5;
          echo "&lt;br&gt;Korting is: $korting %&lt;/br&gt;";
  
          if (isset($_POST["submit"])) {
              switch ($_POST['betalingsmethode']) {
                  case "visa" :
                      echo "&lt;p&gt;Betalingswijze: Visa&lt;/p&gt;";
                      break;
                  case "mastercard" :
                      echo "&lt;p&gt;Betalingswijze: Mastercard&lt;/p&gt;";
                      break;
                  case "paypal" :
                      echo "&lt;p&gt;Betalingswijze: PayPal&lt;/p&gt;";
                      break;
                  case "ideal" :
                      echo "&lt;p&gt;Betalingswijze: iDeal&lt;/p&gt;";
                      break;
                  default:
                      echo "&lt;p&gt;Kies een Betalingsmethode om door te gaan&lt;/p&gt;";
              }
          }
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>