0
GET METHOD GETTING NULL why?
Testing in the browser: [email protected]&senha=1241
Code:
session_start();
class Login
{
private $email;
private $senha;
private $db;
public function __construct(PDO $db){
$this->db = $db;
}
public function autenticar($email, $senha){
$query = "select * from clientes where email='$email' and senha=$senha";
echo $query."<br>";
$stmt = $this->db->prepare($query);
$stmt->execute();
if(($stmt->fetch())){
$_SESSION['logado'] = true;
return true;
}
else{
$_SESSION['logado'] = false;
return false;
}
}
}
$email = htmlspecialchars($_GET['$email']);
$senha = htmlspecialchars($_GET['$senha']);
$db = new PDO("mysql:host=localhost;dbname=registroop","root","");
$login = new Login($db);
$resultado = $login->autenticar($email,$senha);
if($resultado)
echo "logado";
else
echo "não logado";
echo "<br>";
This question is only a misdigestion.
– Inkeliz
Exchange the
$_GET['$email']
for$_GET['email']
and$_GET['$senha']
for$_GET['senha']
. Removing the$
.– Inkeliz
I need to tell you never pass a password via GET?
– Rodrigo