How to show a success / failure message on contact form submit
<p>I'm trying to figure out a simple way to to show that a message was either sent or not in a contact form. At the moment on success or failure it is redirecting to a designated success or failure page. All I'm looking to do is instead of redirect, maybe show a div, or modal or popup but I'm not sure how to do that in PHP.</p>

<p>Form:</p>

<pre><code>&lt;div class="col-lg-7 col-sm-7 contactboxform"&gt;
    &lt;form action="contact_me.php" method="POST" id="contactform"&gt;
      &lt;input type="text" name="name" placeholder="Name..." class="input-text"&gt;
      &lt;input type="text" name="phone" placeholder="Phone Number..." class="input-text"&gt;
      &lt;input type="email" name="email" placeholder="E-mail Address..." class="input-text"&gt;
      &lt;input type="checkbox" name="interested"&gt;
      &lt;textarea name="message" placeholder="What would you like to say?" class="input-text text-area" rows="7"&gt;&lt;/textarea&gt;
      &lt;button type="submit" id="subbtn" class="btn btn-default btn-lg"&gt;Submit&lt;/button&gt;
    &lt;/form&gt;
    &lt;/div&gt;
</code></pre>

<p>PHP:</p>

<pre><code>// send email
if (!empty($name) &amp;&amp; !empty($email) &amp;&amp; !empty($phone) &amp;&amp; !empty($message)) {
    $success = mail($emailTo, $subject, $body, "From: &lt;$emailFrom&gt;");
}
if ($success){
    header('Location: success.html');
}
else {
    header('Location: failed.html');
}
//redirect to success page
</code></pre>

<p>So I'm just not sure how to properly say in PHP that on success, show specific div / popup.</p>

<p>Thanks in advance </p>