title: How to get Twitter Bootstrap modals to stay open on form submit?
body: <p>I am trying to figure out if there is a relatively simple way (I'm not very skilled at JQuery) to keep the modal open after a form submit. (The form is contained in the modal).</p>
  
  <p>If the form is successful or there are errors, my PHP will show them but the modal closes as soon as the submit button is pressed.</p>
  
  <p>If I reload the form, I can see the appropriate success or error message so all is working fine, but I'd prefer the end-user to see the message then click to close the modal afterwards.</p>
  
  <p>I can post my code if that helps.</p>
  
  <p>Thank you.</p>
  
  <pre><code>&lt;?php 
  $success_message = "&lt;h3 class='success'&gt;Thank you, your message has been sent.&lt;/h3&gt;"; 
  $success = false; // we assume it and set to true if mail sent
  $error = false;
  
  // set and sanitize our form field values
  
  $form = array(
    'Name' =&gt; $sanitizer-&gt;text($input-&gt;post-&gt;name),
    'Email' =&gt; $sanitizer-&gt;email($input-&gt;post-&gt;email),
    'Phone number' =&gt; $sanitizer-&gt;text($input-&gt;post-&gt;phone),
    'Type of client' =&gt; $sanitizer-&gt;text($input-&gt;post-&gt;client_type),
    'Service client is after' =&gt; $sanitizer-&gt;text($input-&gt;post-&gt;service),
    'Further information' =&gt; $sanitizer-&gt;textarea($input-&gt;post-&gt;information)
  );
  
  $required_fields = array(
    'name' =&gt; $input-&gt;post-&gt;name,
    'email' =&gt; $input-&gt;post-&gt;email
  );
  
  
  // check if the form was submitted
  if($input-&gt;post-&gt;submit) {
  
    // determine if any fields were ommitted or didn't validate
    foreach($required_fields as $key =&gt; $value) {
      if( trim($value) == '' ) {
        $error_message = "&lt;h3 class='error'&gt;Please check that you have completed all the required fields.&lt;/h3&gt;";
        $error = true;
      }
    }
    // if no errors, email the form results
    if(!$error) {
      $message = "";
      $to_name = "My name";
      $to = "me@me.com";
      $subject = "Contact Form request";
      $from_name = "My Website";
      $from = "do-not-reply@my-site.com";
      $headers = "From: $from_name &lt;$from&gt;";
      foreach($form as $key =&gt; $value) $message .= "$key: $value\n";
  
      require_once("./scripts/PHPMailer/class.phpmailer.php");
  
      $mail = new PHPMailer();
      $mail-&gt;CharSet = "UTF8";
  
      $mail-&gt;FromName = $from_name;
      $mail-&gt;From = $from;
      $mail-&gt;AddAddress($to, $to_name);
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $message;
  
      if ($mail-&gt;Send()) {
        $success = true;
      }
  }
  }
  ?&gt;
  
  
  
  &lt;!-- Contact form made available from every page --&gt;
  
      &lt;div class="modal hide fade" id="form"&gt;
  
  
          &lt;div class="modal-header"&gt;
              &lt;a class="close" data-dismiss="modal"&gt;&amp;times;&lt;/a&gt;
             &lt;h3&gt;Get in touch&lt;/h3&gt;
           &lt;/div&gt;
  
          &lt;div class="modal-body"&gt;
  
          &lt;?php if(!$success) { 
              if($error) {
              echo $error_message; // or pull from a PW field
              } 
          ?&gt;
  
          &lt;form action="./" method="post" class="modal-form"&gt;
  
              &lt;div class="row-fluid"&gt;
                  &lt;fieldset class="span6"&gt;
  
                      &lt;label for="name"&gt;Name:&lt;/label&gt;
                      &lt;input type="text" name="name" required&gt;
  
                      &lt;label for="email"&gt;Email:&lt;/label&gt;
                      &lt;input type="email" name="email" required&gt;
  
                      &lt;label for="phone"&gt;Phone:&lt;/label&gt;
                      &lt;input type="tel" name="phone"&gt;
  
                  &lt;/fieldset&gt; 
  
                  &lt;fieldset class="span6"&gt;
  
                      &lt;label for="client_type"&gt;I am a...&lt;/label&gt;
                      &lt;select name="client_type"&gt;
                          &lt;option&gt;Private student&lt;/option&gt;
                          &lt;option&gt;Business&lt;/option&gt;
                          &lt;option&gt;Unsure&lt;/option&gt;
                      &lt;/select&gt;
  
                      &lt;label for="service"&gt;I am interested in...&lt;/label&gt;
                      &lt;select name="service"&gt;
                          &lt;option&gt;Private tuition&lt;/option&gt;
                          &lt;option&gt;Group tuition&lt;/option&gt;
                          &lt;option&gt;Translation&lt;/option&gt;
                          &lt;option&gt;Unsure&lt;/option&gt;
                      &lt;/select&gt;
  
                  &lt;/fieldset&gt;
              &lt;/div&gt; &lt;!-- /.row-fluid --&gt;
  
  
              &lt;div class="row-fluid"&gt;
                  &lt;fieldset&gt;
                      &lt;label for="information"&gt;Further information:&lt;/label&gt;
                      &lt;textarea name="information" name="information" id="information" class="span12"&gt;&lt;/textarea&gt;
                  &lt;/fieldset&gt;
  
              &lt;button type="submit" name="submit" value="Submit" class="btn"&gt;Submit&lt;/button&gt;
  
              &lt;/div&gt; &lt;!-- /.row-fluid --&gt;
  
              &lt;/form&gt;
  
              &lt;?php }  else {
  
              echo $success_message;
              } ?&gt;
  
          &lt;/div&gt; &lt;!-- /.modal-body --&gt;
  
  
          &lt;div class="modal-footer"&gt;
  
          &lt;/div&gt; &lt;!-- /.modal-footer --&gt;
  
  
      &lt;/div&gt; &lt;!-- /#contact_form.modal hide fade --&gt;
  </code></pre>