title: Why can't I POST data from a Modal to PHP?
body: <p>Using the following code, a modal within a form with method="POST" but in the php-part the submitted value is not read. Can anyone tell me how to accomplish this?</p>
  
  <pre><code>                &lt;?php
                  if ($error) {
                      echo '&lt;div class="alert alert-danger"&gt;'.$error.'&lt;/div&gt;';
                  }
  
                  if ($message) {
                      echo '&lt;div class="alert alert-success"&gt;'.$message.'&lt;/div&gt;';
                  }
                  ?&gt;
  
  &lt;div class="container"&gt; 
      &lt;button class="btn btn-success" data-toggle="modal" data-target="#myModal"&gt;
      Launch modal
      &lt;/button&gt;
  
      &lt;form method="post"&gt;                
  
      &lt;div class="modal" id="myModal"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;h4 class="modal-title"&gt;You will receive an Access Code at your new email-address&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;label for="text"&gt;Fill in your Access Code right here&lt;/label&gt;
                      &lt;input type="text" name="AccessCode" class="form-control"/&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;input type="submit" name="submit" value="Confirm" data-dismiss="modal" class="btn btn-success btn-lg marginTop" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The php part looks like this:</p>
  
  <pre><code>&lt;?php 
  
  if ($_POST['submit']=='Confirm') {
      print_r($_POST);
      $error="No errors";
      $message="Approved!";
  } else {
      $error="Error!";
      $message="Nothing received";
  }
  
  ?&gt;
  </code></pre>