I'm trying to validate a login using row count of a query, but I'm not getting it:
My connection looks like this:
include("defines.php");
try {
$PDO = new PDO('mysql:host=' . HOST . ';dbname=' . DB, USER, PASS );
$PDO->exec("set names utf8");
} catch(PDOException $e) {
echo 'Erro de conexão ao Banco de Dados: ' . $e->getMessage();
}
My form looks like this:
<form class="userform" id="frmLogin" method="post" action="verifica_usuario.php">
<input type="text" size="35" id="usuario" name="usuario" value="<?php echo $_POST['usuario']; ?>" />
<input type="password" size="35" class="bradius" id="senha" name="senha" value="<?php echo $_POST['senha']; ?>" />
<spam class="button" ><a href="#" class="button" onClick="frmLogin.submit();" onMouseOver="window.status='';return true" /> Entrar</a>
</spam>
</form>
The page that does the validation looks like this:
session_start(); // Inicia a session
include "libraries/conn.php";
@$usuario = $_POST['usuario'];
@$senha = $_POST['senha'];
$senhacrip = md5($senha);
$sql = mysql_query("SELECT * FROM usuarios WHERE usuario='{$usuario}' AND senha='{$senhacrip}' AND ativado='S'");
$login_check = mysql_num_rows($sql);
However, when you run the code, the browser returns the message:
Warning: mysql_num_rows () expects parameter 1 to be resource, boolean given in D: \ xampp \ htdocs \ n_archaeus \ verifies_user.php on line 22