user6181297 user6181297 - 1 year ago 44
PHP Question

How to update only once even when user refreshes page the page again?

I want to update only once even when the user refreshes the page many times.How can I do that?


$upd="update books set quantity=quantity-'$quantbuy' where code='$code' ";

HTML form page

<form name="updatebook" action="updateunblockedbooks.php" method="get">
quantity:<br/><input type="number" name="quantbuy" id="quantity" required><br/>
Code:<br/><input type="number" name="code" id="code"><br/>
<input type="submit" value="submit" onclick="return validate2();"><br/>

Is using header after updating a good idea for my question?

Answer Source

You can redirect to that page where this form is filled from or you can redirect to a thank you page and you can also send some message to the redirection page and according to that message value you can display success or error message so the person filling the form knows what happened.

So redirect like this:


And on the page where this redirects to get that msg and display message.