title: PHP multiple redirects
body: <p>I have a $_POST array with a single variable 'listing_type'. The form submits to a page containing the code below which redirects them to another page with more forms dependent on their initial choice. Is there a slicker way to do this? It works fine but feels clunky...</p>
  
  <pre><code>&lt;?php // listing-type.php
  if ((isset($_POST['listing_type'])) &amp;&amp; (!empty($_POST['listing_type']))) {
  
      switch($_POST['listing_type']) {
          case "1":
              $url = "events/new-event.php";
              break;
          case "2":
              $url = "restaurants/new-restaurant.php";
              break;
          case "3":
              $url = "bars/new-bar.php";
              break;
          case "4":
              $url = "attractions/new-attraction.php";
              break;  
      }
  header("Location: $url"); // Perform redirect to given new listing page
  }
  else {  // Redirect to homepage if no usuable listing_type data from form
      $url = "index.php";
      header("Location: $url");
  }
  </code></pre>