php - submit form only on button click not on page refresh -


below code, , working fine.. problem when refresh page , execute success query.

<form action="" method="post"> <input type="submit" value="purchase" id="btn" name="link_credits"> </form>  if(isset($_request['link_credits']))  { echo "success"; //some codes here sql statements } else  {  echo " please try again tomorrow";  }  ?> 

problem:

i don't want run query page refresh, should run code @ button click.

just add line unset($_request['link_credits']); in success loop

if(isset($_request['link_credits']))      {     echo "success";     //some codes here sql statements      if($success){     $_session['msg']="data added successfully";     }     else{     $_session['msg']="data not added successfully.please check";     }     unset($_request['link_credits']);     header("location:--somepage.php--");         }     else      {      echo " please try again tomorrow";      } 

then can show $_session['msg'] value in --somepage.php-- , after showing use unset($_session['msg']);


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -