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 Link to comment https://forums.phpfreaks.com/topic/205453-refresh-button-keep-activate-the-_post-function/ 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. Link to comment https://forums.phpfreaks.com/topic/205453-refresh-button-keep-activate-the-_post-function/#findComment-1075191 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/"); Link to comment https://forums.phpfreaks.com/topic/205453-refresh-button-keep-activate-the-_post-function/#findComment-1075195 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. Link to comment https://forums.phpfreaks.com/topic/205453-refresh-button-keep-activate-the-_post-function/#findComment-1075208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.