How to refresh page and not send duplicate data to the bank in PHP?


I would like to know if anyone has an example or can explain to me in the following question:

In case the user refreshes the page, after submitting the first form, the data is not sent back to MySQL.

My application is in PHP, I've searched, but I still can't solve it.

The application consists of 5 forms in a single table, but filling is one by one.


Another alternative:

is you create a session variable to check if there has already been a request, see:

 if( $_SERVER['REQUEST_METHOD']=='POST' ) { $request = md5( implode( $_POST ) ); if( isset( $_SESSION['last_request'] ) && $_SESSION['last_request']== $request ) { echo 'refresh'; // opa! é refresh! } else { $_SESSION['last_request'] = $request; echo 'é post'; //salva o que tem que ser salvo } } ?>


Scroll to Top