title: Need to prevent new page from opening up when submitting a PHP $_POST form.
body: <p>So basically I am trying to create a form that users can input their name, e-mail, message, etc., click submit, and the information gets compiled and sent to my e-mail address. What happens when you click submit is you get redirected to a new page, joeyorlando.me/php/index.php. </p>
  
  <p>What I would like to have happen upon clicking submit is to have a small box pop up near the submit button saying, "Thanks for your submission" (or something of the sort), and the page not get redirected, instead you would remain on the same page as the form.</p>
  
  <p>How can I prevent the submit button from sending you to this new page? Any advice would be much appreciated!!</p>
  
  <pre><code>&lt;?php
      $firstname = $_POST['firstname'];
      $lastname = $_POST['lastname'];
      $company = $_POST['company'];
      $phone = $_POST['phone'];
      $email = $_POST['email'];
      $message = $_POST['message'];
      $human = $_POST['human'];
  
      $from = 'From: $firstname $lastname'; 
      $to = 'joey@joeyorlando.me'; 
      $subject = 'You Have a New Form Submission!';
      $body = "From: $firstname $lastname\n Company: $company Phone: $phone \n E-Mail: $email\n Message:\n $message";
  
      if ($_POST['submit']) {
          if ($firstname != '' &amp;&amp; $lastname != '' &amp;&amp; $email != '' &amp;&amp; $message != '') {
              if ($human == '14') {
                  if (mail ($to, $subject, $body, $email)) { 
                      echo '&lt;p&gt;Your message has been sent!&lt;/p&gt;';
                  } else { 
                      echo '&lt;p&gt;Something went wrong, go back and try again!&lt;/p&gt;'; 
                  }
              } else if ($_POST['submit'] &amp;&amp; $human != '14') {
                  echo '&lt;p&gt;You answered the question incorrectly!&lt;/p&gt;';
              }
          } else {
          echo '&lt;p&gt;You need to fill in all required fields!!&lt;/p&gt;';
      }
    }
    ?&gt;
  </code></pre>