I'm starting a new system only that instead of procedural I'm using O.O. and PDO, I started to login, but even to select returning the value, PHP shows that user or password is wrong ...
Login method:
static function login($usuario, $senha) {
try {
$con = ConnectionFactory::getConnection();
$con->beginTransaction();
$senha = base64_encode($senha);
$stmt = $con->prepare("select usuario from tbl_login where usuario = '?' and senha = '?'");
$stmt->bindParam(1, $usuario);
$stmt->bindParam(2, $senha);
$stmt->execute();
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
// tentei colocar tmb $stmt->rowCount() == 1
if(count($users) == 1){
echo '<script> alert("Bem vindo ao sistema!");
window.location("menu.php"); </script>';
} else {
echo '<script> alert("Usuário ou senha incorretos!");
window.location("login.php"); </script>';
}
} catch (PDOException $e) {
echo $e->getMessage();
}
}