I'm logging in to the system, but I got to a part that I can not think of as a logic to run. When the user tries to log in and miss the password 3 times, a captcha will appear on the login screen, this I was able to do, I'm having trouble checking if this captcha was created when checking the login. I have the ready if, but I do not know how to implement it ...
code for login 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> ';
}