title: PHP two forms, one page
body: <p>So in school we're learning about OOP in PHP and for our assignment we need to use 2 forms. this is the first time I'm using 2 forms in one page and I've been trying to figure out how to check which form is being submitted and create the according object. 
  Apparently, afer looking at some other questions, just using <code>if (!empty($_POST['SubmitButtonName']))</code> should work, but it doesnt.
  Hope someone can help me and tell me what I'm doing wrong :)</p>
  
  <p>PHP:</p>
  
  <pre><code>if (!empty($_POST['sportwgn'])) 
  {
      try 
      {
         $sport-&gt;Merk = $_POST['merk'];
         $sport-&gt;AantalPassagiers = $_POST['AantalPassagiers'];
         $sport-&gt;AantalDeuren = $_POST['AantalDeuren'];
         $sport-&gt;Stereo = isset($_POST['stereo']) ? true : false;
         $sport-&gt;Save();
         $succes= "Uw sportwagen is gereserveerd!";
      }
      catch( Exception $e)
      {
          $error = $e-&gt;getMessage();
      }
  }
  if (!empty($_POST['vrachtwgn'])) 
  {
      try 
      {
         $vracht-&gt;Merk = $_POST['merk'];
         $vracht-&gt;AantalPassagiers = $_POST['AantalPassagiers'];
         $vracht-&gt;AantalDeuren = $_POST['AantalDeuren'];
         $vracht-&gt;MaxLast = $_POST['MaxLast'];
         $vracht-&gt;Save();
         $succes= "Uw vrachtwagen is gereserveerd!";
      }
      catch( Exception $e)
      {
          $error = $e-&gt;getMessage();
      }
  }
  </code></pre>
  
  <p>Forms:</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
          &lt;label for="merk"&gt;merk&lt;/label&gt;
          &lt;input type="text" id="merk" name="merk"&gt;
          &lt;br&gt;
          &lt;label for="AantalPassagiers"&gt;Aantal passagiers&lt;/label&gt;
          &lt;input type="number" min="2" max="4" id="AantalPassagiers" name="AantalPassagiers"&gt;
          &lt;br&gt;
          &lt;label for="AantalDeuren"&gt;Aantal deuren&lt;/label&gt;
          &lt;input type="number" min="1" max="5" id="AantalDeuren" name="AantalDeuren"&gt;
          &lt;br&gt;
          &lt;label for="stereo"&gt;Stereo?&lt;/label&gt;
          &lt;input type="checkbox" name="stereo" id="stereo" value="stereo"&gt;&lt;br&gt;
          &lt;br&gt;&lt;/div&gt;&lt;div class="box"&gt;
          &lt;button type="submit" name="sportwgn"&gt;Reserveer&lt;/button&gt;&lt;/div&gt;
      &lt;/form&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="container"&gt;
  &lt;h1 class="box"&gt;Reserveer een Vrachtwagen!&lt;/h1&gt;
  &lt;div id="content"&gt;
  
      &lt;form action="" method="post"&gt;
          &lt;label for="merk"&gt;merk&lt;/label&gt;
          &lt;input type="text" id="merk" name="merk"&gt;
          &lt;br&gt;
          &lt;label for="AantalPassagiers"&gt;Aantal passagiers&lt;/label&gt;
          &lt;input type="number" min="2" max="4" id="AantalPassagiers" name="AantalPassagiers"&gt;
          &lt;br&gt;
          &lt;label for="AantalDeuren"&gt;Aantal deuren&lt;/label&gt;
          &lt;input type="number" min="1" max="5" id="AantalDeuren" name="AantalDeuren"&gt;
          &lt;br&gt;
          &lt;label for="MaxLast"&gt;Max last&lt;/label&gt;
          &lt;input type="number" min="1" max="5" id="MaxLast" name="MaxLast"&gt;&lt;br&gt;
          &lt;br&gt;&lt;/div&gt;&lt;div class="box"&gt;
          &lt;button type="submit" name="vrachtwgn"&gt;Reserveer&lt;/button&gt;&lt;/div&gt;
      &lt;/form&gt;
  </code></pre>