Jump to content

Refresh button keep activate the _POST function


sungpeng

Recommended Posts

<?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

 

 

<?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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.