I have a php webpage with a form. After filling out the form on the web page, I can send it to the server. But after that, if I refresh the page, it inserts the same record into the database. Are there any solutions to this problem?
Use the POST / Redirect / GET pattern . This will not allow the user to resubmit the same form.
There are several ways, for example:
, . , , - , . , , , .
, , Refresh : " ".
, , , . , .
, , , , , . . , " " " " "".
, , .
process.php action.
action
process.php
//code to insert item to database header('Location: YOUR_FORM_PAGE_HERE);
INSERT IGNORE INTO table_name ...
.