PHP-当我按F5键时如何删除“确认表格重新提交”?

时间:2019-01-31 06:34:41

标签: php forms mysqli

问题-当我提交按钮时,它会更新我的记录,但是当我按F5键时会弹出一个Confirm Form Resubmission - The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue?弹出窗口,因此如果我按是,则更新记录将更改。我可以删除它还是对此有任何解决方案?

预期的输出 -我只想删除该弹出窗口,并只一次更新我的表单,而不是重复一次,这样我就可以一次更新记录。谢谢!!!

我的代码

      <?php

  //CONNECTION
  $connection =mysqli_connect("localhost","root","");
  $db = mysqli_select_db($connection,'inflightapp');

  //END CONNECTION

  //SUBMIT THE INPUT AND SEARCH THE LIKE VALUE
  if (isset($_POST['search'])) {
  $txtCode = $_POST['id'];
  //GET THE INPUT BELOW AMOUNT

  //REMOVE THE SPECIAL CHARACTER QR CODE: | TO READ AND SEARCH FOR SIMILAR VALUE
  $hashCase =  $txtCode;
  $str = ltrim( strstr($hashCase,":"),":");
  $strFinalString = trim(substr($str,0,strpos($str, "|")));
  //END OF REMOVING SPECIAL CHAR


  //QUERY TO SEARCH THE VALUE
  $query = "SELECT * FROM scratch_cards WHERE code LIKE '%$strFinalString%' ";
  $query_run = mysqli_query($connection,$query);
  //END

  //FETCH THE DATA INTO MY DATABASE 'scratch_cards'
  while($row = mysqli_fetch_array($query_run))
  {
   $txtValue = $row['amount'];
    $txtStatus = $row['status'];
  ?>
      <input type="hidden" name="amount[<?php echo $row['id'] ?>]" value="<?php echo $row['amount'] ?>">
       <input type="hidden" name="stats[<?php echo $row['id'] ?>]" value="<?php echo $row['status'] ?>">
      <h2 id="closeVal"><i><u>You have received: <?php echo '<b style="color:#90EE90">'.$row['amount'].'</b>'  ?> Coins</u></i></h2>



  <?php



    //QUERY TO UPDATE THE VALUE
  $query2 = "UPDATE shopusers SET ewallet = ewallet + " . (0 + $txtValue) . " WHERE id = '$id' ";
  $query_run2 = mysqli_query($connection,$query2);
  //END

0 个答案:

没有答案