0
I have a registration system, which does not allow the user to register with an already registered email, but when I register with an existing email, it does not redirect the user to the registration page. I used the tag header='Location(cadastro.php?erro=1)'
.
Is there any other tag that can be used? Or what could be wrong for it not to be redirecting?
Here is the php code that tries to register in the database:
<?php
session_start();
require_once('conecta.php');
// RECEBENDO OS DADOS PREENCHIDOS DO FORMULÁRIO !
$nome = $_POST ["nome"];
$data = $_POST ["data"];
$email = $_POST ["email"];
$email2 = $_POST ["email2"];
$senha = $_POST ["senha"];
$arq = $_FILES['foto']['name'];
$arq = $_FILES['foto']['name'];
$arq = str_replace(" ", "_", $arq);
$arq = str_replace("ç", "c", $arq);
if (file_exists("imagens/".$arq)) {
$a = 1;
while (file_exists("imagens/[".$a."]".$arq)) {
$a++;
}
$arq = "[".$a."]".$arq;
}
if (move_uploaded_file($_FILES['foto']['tmp_name'], 'imagens/'.$arq)) {
$objDb = new db();
$link = $objDb->conecta_mysql();
$sql = "insert into voluntarios (nome, data, email, email2, senha, foto) values ('$nome', '$data', '$email', '$senha', '".$arq."')";
if (mysqli_query($link, $sql)){
echo '<nav class="navbar navbar-fixed-top navbar-inverse navbar-transparente">
<div class="container">
<!-- Header -->
<div class="navbar-header">
<!-- botao toggle -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#barra-navegacao">
<span class="sr-only">Alternar navegação</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.php" class="navbar-brand">
<span><img src="imagens/logoviladobem.png" width="80px"></span>
</a>
</div>
<!-- navbar -->
<div class="collapse navbar-collapse" id="barra-navegacao">
<ul class="nav navbar-nav navbar-right">
<li><a href="sobre.php">Sobre</a></li>
<li class="divisor" role="separator"></li>
<li><a href="facaparte.php">Faça Parte</a></li>
<li><a href="entrar.php">Entrar</a></li>
</ul>
</div>
</div>
</nav>
<div class="capa">
<div class="texto-capa">
<h1>Parabéns por ter tido essa inciativa, seu cadastro foi realizado com sucesso!</h1>
<h3>Um e-mail foi enviado para o e-mail cadastrado com algumas informações importantes.</h3>
</div>
</div>';
} else {
header('Location: cadastro.php?erro=1');
}
} else {
header('Location: cadastro.php?erro=1');
}
?>
Is he falling into Isis? because the header command is right.
– Leonardo Bonetti
@Leonardobonetti is falling yes, I put an echo to check if it was falling, and he ran normally
– Arthur Oliveira