I searched all corners of the internet but could not find anything like my problem. I have a registration form that after doing the INSERT in the database shows a modal window and inside it a success or error message along with an "OK" button. This works fine by pressing OK it closes the modal and displays the registration page again. My problem is that if the user before pressing "OK" gives an "F5" the "Confirm form resubmit" dialog box is displayed and if you click "Continue" it duplicates the INSERT and consequently the registration in the bank
HereisthePHPsummarycode:
if (isset($_POST['cadastrar'])) {
<!-- aqui vão os requires dos includes com os dados do banco-->
$sql = "INSERT";
$resultado mysqli_query($conexao, $sql) or die (mysqli_error($conexao));
$linhas = mysqli_affected_rows($conexao);
if($linhas > 0){
$mensagem = "Seu cadastro foi feito com sucesso!";
} else {
$mensagem = "Erro ao cadastrar!";
}
<!-- aqui vai o require include de desconexão-->
<!--o código abaixo chama a janela modal-->
?><script>$(document).ready(function() {
$('#myModal').modal('show');
});</script>
<?php
}
?>