php - MySQLi queries runs on each browser refresh -
when run code, "insert aks_balance_history" query , "update aks_account" query runs again , again.also database getting updated on each refresh, while "update aks_counter" runs once (as required). stuck in code please help.
if(isset($_post['update_btn_counter'])) { mysqli_query($link,"insert aks_balance_history(bh_amount,bh_from,bh_to,bh_reason) values('".$_post["used_balance"]."','counter cash','".$_post["select_account"]."','".$_post["reason"]."') "); mysqli_query($link,"update aks_counter set counter_balance = counter_balance - '$_post[used_balance]' counter_id='0' "); mysqli_query($link,"update aks_account set account_balance = account_balance + '$_post[used_balance]' account_title='$_post[select_account]' "); }
sure, because browser sends same request again. asked to when refreshing. if want prevent that, have redirect browser after having performed database operations. typically redirect read code reads result database , displays it. can refresh how want.
currently not reload form, result of form got after first submit. re-deliver result server must re-run same code, same operations performed.
a typical solution send forms submission processing script , redirect form if should offered again.
Comments
Post a Comment