1
I’m logging in the system, but I’ve reached a point where I can’t think of a logic to execute. When the user tries to log in and misses the password 3 times, a captcha will appear on the login screen, that I was able to do, I have problem to check if this captcha was created when checking the login. I have the if ready, but I don’t know how to implement it...
login code without verification:
if ($_POST) {
$user = $_POST['txtu'];
$senha = $_POST['txts'];
session_start();
if (efetuarLogin($conexao, $user, $senha)) {
session_start();
$_SESSION['nome'] = $user;
$cpf = pegaCpfUsuarioLogado($conexao, $user);
$_SESSION['tipoUsuario'] = pegaTipoUsuario($conexao, $cpf);
mysqli_close($conexao);
if ($_SESSION['tipoUsuario'] == 2) {
$_SESSION['log'] = 'ativo';
header("location: pag_pesquisarTec.php");
} else {
$_SESSION['log'] = 'ativoTecnico';
header("location: pag_listar_chamados.php");
}
} else {
// contabiliza os erros;
if (empty($_SESSION['numErros'])) {
$_SESSION['numErros'] = 1;
} else {
$_SESSION['numErros'] ++;
}
echo '<script> var r = confirm("Senha ou usuário incorreto!")
if (r === true) {
window.location.assign("index.html");
} else {
window.location.assign("index.html");
}
</script>';
}
}
if to check the captcha:
if ($_POST["palavra"] == $_SESSION["palavra"]) {
} else {
echo '<script>alert("Captcha errado!");'
. 'window.location = "index.html"</script> ';
}