title: Display success message after submit form modal
body: <p>I have a contact form linked with form-to-email.php to send emails. 
  What happen is when you click submit it will redirect you to another page (new one) what I would like to have is to show/display the success message within the modal right after clicking the botton. </p>
  
  <pre><code>&lt;div class="modal fade" id="modal-register" tabindex="-1" role="dialog" aria-labelledby="modal-register-label" aria-hidden="true"&gt;
  &lt;div class="modal-dialog"&gt;
  &lt;div class="modal-content"&gt;
                          &lt;div class="modal-header"&gt;
                          &lt;button type="button" class="close" data-dismiss="modal"&gt;
                              &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;
                          &lt;/button&gt;
                          &lt;h4 class="modal-title" id="modal-register-label"&gt;اشتراك&lt;/h4&gt;
                      &lt;/div&gt;
  &lt;div class="modal-body"&gt;
  &lt;form method="post" name="myemailform" action="form-to-email.php"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-xs-12 input-group"&gt;
            &lt;input type="radio" name="form-busnisstype" value="company" id="company"&gt;
            &lt;label for="company"&gt;شركة&lt;/label&gt;
            &lt;input type="radio" name="form-busnisstype" value="freelaancer" id="freelancer"&gt;
            &lt;label for="freelancer"&gt;مستقل&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="col-xs-12 input-group"&gt;
          &lt;input type="text" name="form-name" id="name" placeholder="الاسم الكريم" required="required"&gt;
        &lt;/div&gt;
        &lt;div class="col-xs-12 input-group"&gt;
          &lt;input type="email" name="form-email" id="email" placeholder="البريد الالكتروني" required="required"&gt;
        &lt;/div&gt;
        &lt;div class="col-xs-12 input-group"&gt;
            &lt;input type="tel" pattern="^[0-9]*$" name="form-phone" id="phone" placeholder="05xxxxxxxx" required="required"&gt;
        &lt;/div&gt;
          &lt;div class="col-xs-12 input-group"&gt;
            &lt;select name="form-officetype" id="officetype" required="required"&gt;
                  &lt;option value="" disabled selected hidden="" &gt;اختر مكتبك&lt;/option&gt;
                  &lt;option value="Gold"&gt;individual&lt;/option&gt;
                  &lt;option value="Silver"&gt;room&lt;/option&gt;
                  &lt;option value="Bronze"&gt;meeting&lt;/option&gt;
                  &lt;option value="Basic"&gt;orgonization&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 input-group"&gt;
            &lt;select name="form-membership" id="membership" required="required"&gt;
                  &lt;option value="" disabled selected hidden="" &gt;اختر باقتك&lt;/option&gt;
                  &lt;option value="Gold"&gt;Gold&lt;/option&gt;
                  &lt;option value="Silver"&gt;Silver&lt;/option&gt;
                  &lt;option value="Bronze"&gt;Bronze&lt;/option&gt;
                  &lt;option value="Basic"&gt;Basic&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-xs-12 input-group input-group-icon"&gt;
          &lt;input placeholder="بداية الاشتراك" type="text" onfocus="(this.type='date')" id="booking" name="form-booking" required="required"&gt;
        &lt;/div&gt;
          &lt;div class="col-xs-12 input-group input-group-icon"&gt;
            &lt;select name="form-person" id="person" required="required"&gt;
            &lt;option value="" disabled selected hidden="" &gt;كم عدد الاشخاص&lt;/option&gt;
                  &lt;option value="1"&gt;1 Person&lt;/option&gt;
  &lt;option value="2"&gt;2 People&lt;/option&gt;&lt;option value="3"&gt;3 People&lt;/option&gt;&lt;option value="4"&gt;4 People&lt;/option&gt;&lt;option value="5"&gt;5 People&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
          &lt;textarea id="mep_msg" name="form-message" rows="" Placeholder="Comment" required="required"&gt;&lt;/textarea&gt;
          &lt;input class="send_btn" type="submit" name='submit' value="submit"&gt;
  
        &lt;/div&gt;    
      &lt;/form&gt;
  
  &lt;script language="JavaScript"&gt;
  var frmvalidator  = new Validator("myemailform");
  frmvalidator.addValidation("name","req","Please provide your name"); 
  frmvalidator.addValidation("email","req","Please provide your email"); 
  frmvalidator.addValidation("tel","tel","Please enter a valid email address"); 
  frmvalidator.addValidation("email","email","Please enter a valid email address"); 
  &lt;/script&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!--Success pop up Starts--&gt;
  &lt;div class="modal fade" id="success_msg" role="dialog" tabindex="-1"&gt;
  &lt;div class="success"&gt;
    &lt;div class="modal-dialog-success"&gt;
      &lt;div class="col-xs-12 pade_none"&gt;
        &lt;button type="button" class="close" onClick="closeConfirm();" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
        &lt;div class="col-xs-12 pade_none"&gt;
          &lt;h2&gt;Success!&lt;/h2&gt;
          &lt;p&gt;Your message has been sent.&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class="col-xs-12 pad_none"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;!--Success pop up ends--&gt;
  </code></pre>
  
  <p>and the form-to-email.php is the following:</p>
  
  <pre><code>&lt;?php
  
  /* Configuration */
  $subject = 'Membership Enquiry'; // Set email subject line here
  $mailto  = 'email here'; // Email address to send form submission to
  /* END Configuration */
  
  $name = $_POST['form-name'];
  $visitor_email = $_POST['form-email'];
  $message = $_POST['form-message'];
  $phone = $_POST['form-phone'];
  $busnisstype = $_POST['form-busnisstype'];
  $officetype = $_POST['form-officetype'];
  $membership = $_POST['form-membership'];
  $person = $_POST['form-person'];
  $booking = $_POST['form-booking'];
  
  // HTML for email to send submission details
  $body = "
  &lt;br&gt;
  &lt;p&gt;The following information was submitted through the contact form on your website:&lt;/p&gt;
  &lt;p&gt;&lt;b&gt;الاسم&lt;/b&gt;: $name&lt;br&gt;
  &lt;b&gt;الايميل&lt;/b&gt;: $visitor_email&lt;br&gt;
  &lt;b&gt;رقم الجوال&lt;/b&gt;: $phone&lt;br&gt;
  &lt;b&gt;نوع المشأة&lt;/b&gt;: $busnisstype&lt;br&gt;
  &lt;b&gt;المكتب المرغوب&lt;/b&gt;: $officetype&lt;br&gt;
  &lt;b&gt;العضوية&lt;/b&gt;: $membership&lt;br&gt;
  &lt;b&gt;عدد الاشخاص&lt;/b&gt;: $person&lt;br&gt;
  &lt;b&gt;التاريخ المتوقع لبدء الاشتراك&lt;/b&gt;: $booking&lt;br&gt;
  &lt;p&gt;ملاحضات اخرى: &lt;b&gt;$message&lt;/b&gt;&lt;/p&gt;
  ";
  
  
  $headers = "From: $name &lt;$visitor_email&gt; \r\n";
  $headers .= "Reply-To: $email \r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  $message = "&lt;html&gt;&lt;body&gt;$body&lt;/body&gt;&lt;/html&gt;";
  
  if (mail($mailto, $subject, $message, $headers)) {
      header('Location: thank-you.html');
  } else {
      echo 'Form submission failed. Please try again...'; // failure
  }
  
  ?&gt;
  </code></pre>