1
I made a login and registration system, and within the registration section I put a condition, if true register, if false do not register. However, as much as if Else is true, when I enter the database, the registration was not carried out. How do I solve this problem?
require_once ('connect.php');
//recebendo os dados
$user = $_POST['user'];
$email = $_POST['email'];
$senha = md5($_POST['senha']);
$rsenha = $_POST['rsenha'];
$birth = $_POST['birth'];
if($connect==true){
//inserindo os dados
$cadastro = mysqli_query($connect,"INSERT INTO Usuarios (user, email, senha, birth, cadastro) VALUES ('$user', '$email', '$senha', '$birth', NOW())");
echo "<script>
alert('Cadastro efetuado com sucesso, basta logar!!');
window.location.href='../index.php';
</script>";
}else{
echo "<script>
alert('Não foi possível se cadastrar, tente novamente mais tarde');
window.location.href='../Cadastro.php';
</script>";
}
That’s the code, thank you all for helping :)
Whenever an answer solves your difficulty mark it as accepted, see https://i.stack.Imgur.com/evLUR.png and what it means in https://answall.com/help/accepted-answer
– user60252
Logical error, your condition will issue an alert if your connection works, regardless of saving the data or not.
– Vinicius De Jesus