0
I’m trying to validate a login using line count of a query, but I’m not getting it:
My connection is 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 is 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 is 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 executing 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 verifica_usuario.php on line 22
printa o var_dump($sql); para saber o que está chegando. e tb var_dump("SELECT * FROM usuarios WHERE usuario='{$usuario}' AND password='{$senhacrip}' AND activator=’S'"); to see the select q is mounting
– Israel Zebulon
You are opening the connection using PDO and using
mysql
to work in the bank. Study a little about the PDO library so you don’t need to use another library to access the bank.– Rodrigo Tognin