title: Add records to mysql database with php form without leaving/refreshing the page
body: <p>I use this file <strong>input.php</strong> to add record to database:</p>
  
  <pre><code>$order = "INSERT INTO wp_userdata
              (username, product_name, product_brand)
              VALUES
              ('$_POST[username]',
                          '$_POST[name]',
              '$_POST[brand]')";
  
  
  $result = mysql_query($order);  
  if($result){
      header( 'Location: http://page-with-form.php' ) ;
  } else{
      echo("&lt;br&gt;Input data is fail");
  }
  </code></pre>
  
  <p>And my page with form <strong>page-with-form.php</strong>:</p>
  
  <pre><code>&lt;table border="1"&gt;
    &lt;tr&gt;
      &lt;td align="center"&gt;Add Products&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;
        &lt;table&gt;
          &lt;form method="post" action="input.php"&gt;
  &lt;input type="hidden" name="username" value="[insert_php]echo $username;[/insert_php]"&gt;
          &lt;tr&gt;
            &lt;td&gt;Product Name&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="name" size="50"&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Brand&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="brand" size="50"&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;/td&gt;
            &lt;td align="right"&gt;&lt;input type="submit" name="submit" value="Send"&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/form&gt;
          &lt;/table&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Everything works fine: When I click "Send" button, input.php adds record and redirects back to page-with-form.php. You can't even see input.php loading, however you do see the page-with-form.php getting refreshed.</p>
  
  <p>Is there a way to make all the operation without refreshing the page-with-form.php? I think it has to do with Ajax, but maybe there is another way? looking forward for your suggestions!</p>