sungpeng Posted June 21, 2010 Share Posted June 21, 2010 <?php if($_POST[action]=="submit") { $insert_student=mysql_query("UPDATE login SET credit = credit - 1"); $_POST[action] = NULL; unset($_POST[action]); } ?> <HTML> <body> <form name="form" action="<?php print $PHP_SELF ?>" method="post"> <input type="submit" name="action" value="submit"> </form> </BODY> </HTML> Good day, Check when i click on the submit button, it will execute "UPDATE credit". Then when i click on the refresh button, it will execute "UPDATE credit" again. I need to destroy the _POST[action]==submit so that when I click on refresh button it will not execute the "UPDATE credit".. pls help.. I tried the whole day still cannot work Quote Link to comment Share on other sites More sharing options...
aeroswat Posted June 21, 2010 Share Posted June 21, 2010 <?php if($_POST[action]=="submit") { $insert_student=mysql_query("UPDATE login SET credit = credit - 1"); $_POST[action] = NULL; unset($_POST[action]); } ?> <HTML> <body> <form name="form" action="<?php print $PHP_SELF ?>" method="post"> <input type="submit" name="action" value="submit"> </form> </BODY> </HTML> Good day, Check when i click on the submit button, it will execute "UPDATE credit". Then when i click on the refresh button, it will execute "UPDATE credit" again. I need to destroy the _POST[action]==submit so that when I click on refresh button it will not execute the "UPDATE credit".. pls help.. I tried the whole day still cannot work You could set a session variable to say that the form was submitted and then on each load of the page check if that session variable is set before u check for the submit button. Either that or you can redirect to a new page. Quote Link to comment Share on other sites More sharing options...
thomashw Posted June 21, 2010 Share Posted June 21, 2010 Redirect to the same page, but without the $_POST's. header("Location: http://www.example.com/"); Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted June 21, 2010 Share Posted June 21, 2010 Send to another page & store the credit info someplace in a hidden field from the DB you are using. Then before updating, check the one in the hidden field against the one in the database to be sure of not double updating. Then you can redirect back to original page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.