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

 

 

Link to comment
Share on other sites

<?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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.