title: Add Second Times to Database Without Refresh Page
body: <p>I use the following code to stop the page refreshing problem. This code  only inserts data in to the database the first time. When I want to insert a second time I must refresh the page. Please help</p>
  <p>below is form that user can inter some info into textbox</p>
  
  <pre class="lang-html prettyprint-override"><code>    form  method='Get' action=&quot;insert.php&quot;  id='myform' &gt;
      &lt;input type=&quot;text&quot; name=&quot;Description&quot; id=&quot;Description&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;Unitys&quot; id=&quot;Unitys&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;quantitys&quot; id=&quot;quantitys&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;Text1s&quot; id=&quot;Text1s&quot;&gt;
      
      &lt;input type=&quot;text&quot; name=&quot;PurchaseQty&quot; id=&quot;PurchaseQty&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;Amount1&quot; id=&quot;Amount1&quot;&gt;
      
      &lt;input class=&quot;button is-info is-large&quot; id=&quot;btn_save&quot; name=&quot;btn_save&quot; type=&quot;button&quot; value=&quot;Save&quot; onclick=&quot;myFunctions();reflash()&quot; /&gt;
      &lt;p id='result'&gt;&lt;/p&gt;           
      
      &lt;/form&gt;
  </code></pre>
  <p>this code below is to stop page refreshing after click the button</p>
  <pre class="lang-js prettyprint-override"><code>    &lt;script&gt;
  $(document).ready(function(){
  $('#btn_save').click(function(){
      var data=$('#myform').serialize()+'&amp;btn_save=btn_save';
      $.ajax({
          url:'insert.php',
          type:'Get',
          data:data,
          success:function(response){
          $('#result').text(response);
      $('#Description').text('');
      $('#Unitys').text('');
      $('#quantitys').text('');
      $('#Text1s').text('');
    $('#PurchaseQty').text('');
    $('#Amount1').text('');
          }
      });
  });
  });
  
  &lt;/script&gt;
  </code></pre>
  <p>This below is insert to php another</p>
  
  <pre class="lang-php prettyprint-override"><code>    if (isset($_GET['btn_save'])){
      
      $DescriptionZ =mysqli_real_escape_string($con,$_GET['Description']);
      $UnityZ = mysqli_real_escape_string($con,$_GET['Unitys']);
      $quantityZ =mysqli_real_escape_string($con,$_GET['quantitys']);
      $TextZ = mysqli_real_escape_string($con,$_GET['Text1s']);
      $PurchaseQtyZ = mysqli_real_escape_string($con,$_GET['PurchaseQty']);
      $AmountZ= mysqli_real_escape_string($con,$_GET['Amount1']);
      
      
      $sql= &quot;INSERT INTO `orders`(`id`, `OrderID`, `Description`, `Unit`, `Quantity`, `Cost`, `Purchasing Qty`, `Amount`) 
      VALUES (NULL,'[555]','$DescriptionZ','$UnityZ','$quantityZ','$TextZ','$PurchaseQtyZ','$AmountZ')&quot;;
        $query=mysqli_query($con,$sql) or die(mysqli_error($con));
        if($query)
        {
            echo &quot;Data Saved Successfully&quot;;
            
        } else {
            echo &quot;Failed to save data&quot;;
        }
      }
  
  &lt;!--end of insert.php--&gt;
  </code></pre>