title: How do I return a message after submitting a form on my page with PHP?
body: <p>I just followed <a href="http://tangledindesign.com/how-to-create-a-contact-form-using-html5-css3-and-php/" rel="nofollow">this tutorial</a> on how to create a contact form with PHP. Now everything works fine but when I submit a form it returns a message on a new blank page. I want this to happen on the current page underneath the contact form.</p>
  
  <p>This is my first time ever doing anything with PHP so I have no idea how I would do this. In the tutorial it is briefly mentioned that you can just put the script anywhere you would want the message to appear but it doesn't seem to work for me.</p>
  
  <p>This is my HTML code:</p>
  
  <pre><code>&lt;form method="post" action="contact.php"&gt;
            &lt;label&gt;Name&lt;/label&gt;
            &lt;input name="name" placeholder="John Doe"&gt;
  
            &lt;label&gt;Email&lt;/label&gt;
            &lt;input name="email" type="email" placeholder="john@doe.com"&gt;
  
            &lt;label&gt;Message&lt;/label&gt;
            &lt;textarea name="message" placeholder="Hello..."&gt;&lt;/textarea&gt;
  
            &lt;label id="antispam"&gt;What is 2+2? (Anti-spam)&lt;/label&gt;
            &lt;input id="antispambox" name="human" placeholder="4"&gt;
  
            &lt;input id="submit" name="submit" type="submit" value="Submit"&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>and this is my PHP code:</p>
  
  <pre><code>&lt;?php
      $name = $_POST['name'];
      $email = $_POST['email'];
      $message = $_POST['message'];
      $from = 'From: TangledDemo';
      $to = 'contact@tangledindesign.com';
      $subject = 'Hello';
      $human = $_POST['human'];
  
      $body = "From: $name\n E-Mail: $email\n Message:\n $message";
  
      if ($_POST['submit']) {
          if ($name != '' &amp;&amp; $email != '') {
              if ($human == '4') {
                  if (mail ($to, $subject, $body, $from)) {
                      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 != '4') {
                  echo '&lt;p&gt;You answered the anti-spam question incorrectly!&lt;/p&gt;';
              }
          } else {
              echo '&lt;p&gt;You need to fill in all fields!!&lt;/p&gt;';
          }
      }
  ?&gt;
  </code></pre>
  
  <p>I've already found some answers but none of which make any sense to me. I also tried inspecting the example on the tutorial's site but, ofcourse I can't access the PHP.</p>
  
  <p>Can anybody explain this to me?</p>