title: Submitting html data and staying on same page
body: <p>I have a form page </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
      &lt;form action="insert.php" method="post"&gt;
          App Name: &lt;input type="text" name="fname" /&gt;&lt;br&gt;&lt;br&gt;
          App ID: &lt;input type="text" name="lname" /&gt;&lt;br&gt;&lt;br&gt;
  
          &lt;input type="submit" name="SubmitButton"/&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is the php page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;?php
      $con = mysql_connect("xxx","xxx","xxx");
      if (!$con)
      {
        die('Could not connect: ' . mysql_error());
      }
  
      mysql_select_db("db", $con);         
      $sql="INSERT INTO app (fname, lname) VALUES('$_POST[fname]','$_POST[lname]')";
  
      if (!mysql_query($sql,$con))
      {
        die('Error: ' . mysql_error());
      }
  
      echo "1 record added";
  
      mysql_close($con)
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now, I want it to display <code>1 record added</code> on the same page as the form and not have the form send me to a new insert.php page with it. Basically, I want the submit form to stay in the same page with maybe a a new message popping up to show that it has worked.</p>
  
  <p>I have already looked through some answers on stackoverflow like using</p>
  
  <pre><code>if(isset($_POST['SubmitButton']))
  </code></pre>
  
  <p>but it doesn't work. Maybe I placed it wrong or used it incorrectly but could someone help me figure it out?</p>