-2
I’m trying to check the bank to know if you already have a user with registered email typed by hmtl, I did this php script, but the execution always stops at the first if even if the email typed is not in the bank yet.
I believe that the logic I used is correct, I can’t identify where I’m going wrong
<?php
include_once("conexao_class.php");
include_once("usuario_class.php");
$My = new MySQLiConnection();
$nome = $_POST['nome'];
$sobrenome = $_POST['sobrenome'];
$email = $_POST['email'];
$sexo = $_POST['sexo'];
$telefone_fixo = $_POST['telefone'];
$telefone_movel = $_POST['celular'];
$senha = $_POST['senha'];
$obj_usu = new usuario($nome,$sobrenome,$telefone_fixo,$telefone_movel,$email,$sexo,$senha);
$My = new MySQLiConnection();// conecta-se automaticamente ao servidor MySQL
$verifica = "SELECT * FROM tb_usuario WHERE nm_email = '$email'";
// a conexão é fechada automaticamente no fim do script.
// retornando a falta de paramentro ao ajax
$result = $My->query($verifica) or die(mysql_error());
if (mysqli_num_rows($result)<=0)
{
if(isset($_POST['terms']))
{
$result2 = $obj_usu->AddUsuario();
echo"$result2";
}
else{
// retornando ao ajax dados inválidos
echo"3";
}
}
else{
// retornando ao ajax email já cadastrado
echo"1";
}
?>
The logic is correct, who knows the error is in another part of the code not posted. Probably in the email input
– user60252
i checked input and is correct, test also return the email variable to see if it was filled and actually returned the email, I have no idea where is the error
– Reignomo
You just can’t go back
echo"3";
– user60252
When an answer solves your problem, do not answer in the answer box and do not need to thank in comments, just mark the answer as accepted. See how in https://i.stack.Imgur.com/evLUR.png and why in https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079
– user60252