I have a page where the form is with an action that sends the form information to another page.
I would like a confirmation message (or denial) to be displayed after the registration has been entered, and after clicking the OK button, there would be a redirect to the original page.
The form page looks like this:
<form id="frmCad" name="frmCad" method="post" action="../inc/processa.php?modo=incluir&fnc=<?php echo $fnc; ?>&ans=<?php echo $linha; ?>">
The proxessa.php file looks like this:
$fnc = $_GET['fnc'];
$linha = $_GET['ans'];
if($modo == "incluir"){
$sql = "INSERT INTO 'pe_premorc' (etc)
$linhafec = mysqli_affected_rows($conexao);
if($linhafec == 1){
echo "<script>alert('Premissa incluída com sucesso');</script>";
header('Location: ../views/premorc.php?fnc=$fnc&ans=$linha');
} else {
echo "<script>alert('Ocorreu um erro. A premissa não foi incluída');</script>";
header('Location: ../views/premorc.php?fnc=$fnc&ans=$linha');
}
But I'm not getting the desired effect. Or it displays the message and it stays on the same page, or it does not display the message and it redirects with the wrong parameters, like link $ fnc & ans = $ line