title: PHP Form Data Checking Submit Button Name
body: <p>I have two forms on the same page, each with different fields and different submit button names.</p>
  
  <pre><code>&lt;button type="submit" name="formOne"&gt;Submit form&lt;/button&gt;
  &lt;button type="submit" name="formTwo"&gt;Submit form&lt;/button&gt;
  </code></pre>
  
  <p>On my <code>mailer.php</code> page I would like to check which submit button has been clicked, and process the code accordingly.</p>
  
  <p>The code I have so far works for a single form, as follows;</p>
  
  <pre><code>if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
      // my form 1 data
      // do stuff
  }
  </code></pre>
  
  <p>However I thought I coulld add an <code>if/else</code> to check which submit button was clicked, something like;</p>
  
  <pre><code>if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
      if($_POST['formOne']){
          // form 1 data
          // my form 1 data
          // do stuff
      }
      if($_POST['formTwo']){
          // form 2 data
          // my form 2 data
          // do stuff
      }
  }
  </code></pre>
  
  <p>This doesn't seem to work. The error I receive is;</p>
  
  <blockquote>
    <p>Notice: Undefined index: formOnein ... line 7</p>
  </blockquote>
  
  <p>How can I achieve this?</p>