title: php send mail and show success message in the same page
body: <p>I have a small form in html like this :</p>
  
  <pre><code> &lt;form id="contact" action="contact.php" method="post"&gt; 
    &lt;table class="contact" width="400" border="0" cellspacing="2" cellpadding="0"&gt; 
      &lt;tr&gt;
        &lt;td &gt;Your name:&lt;/td&gt; 
        &lt;td &gt;&lt;input name="name" type="text" id="name" size="32"&gt;&lt;/td&gt; 
      &lt;/tr&gt;
      &lt;tr&gt; 
        &lt;td&gt;Email address:&lt;/td&gt; 
        &lt;td&gt;&lt;input name="email" type="text" id="email" size="32"&gt;&lt;/td&gt; 
      &lt;/tr&gt;
      &lt;tr&gt; 
        &lt;td&gt;Comment:&lt;/td&gt; 
        &lt;td&gt;
          &lt;textarea name="comment" cols="45" rows="6" id="comment" &gt;&lt;/textarea&gt;
        &lt;/td&gt; 
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td colspan="2" style="text-align:center;"&gt;
          &lt;input type="submit"  value="Submit" style="padding: 3px 22px;" /&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>In contact.php file I have the code like this :</p>
  
  <pre><code>    if (isset($_POST['submit'])) 
      { 
        $name = $_POST['name'];
        $email = $_POST['email'];
        $ToEmail = 'test@test.com';
        $EmailSubject = 'Site contact form '; 
        $mailheader = "From: ".$_POST["email"]."\r\n"; 
        $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
        $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
        $MESSAGE_BODY = "Name: ".$_POST["name"]."&lt;br&gt;"; 
        $MESSAGE_BODY .= "Email: ".$_POST["email"]."&lt;br&gt;"; 
        $MESSAGE_BODY .= "Subject:".$_POST['subject']."&lt;br /&gt;";  
        $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."&lt;br&gt;"; 
        mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
       }
    ?&gt;
  </code></pre>
  
  <p>Now this one is working fine. But when user clicks on submit button it just redirects to the contact.php file. I want that when user will click on the button it will show the success message in the same html file in form of lightbox and the message will be also sent. So can someone tell me how to do this? Any help and suggestions will be really appreciable. Thanks</p>
  
  <p><strong>Update</strong></p>
  
  <p>I have two different files. The form is inside "contact.html" and the form action is "contact.php" and I want to show the "success" and "failure" message in "contact.html" page without going to "contact.php".</p>