1
I am trying to log into the system using PHP database but even using the correct email and password, it does not connect. I believe you really can’t find the record, since it goes through the query but not the following if.
Follow the Login.class:
<?php
class Login{
public function logar($email, $senha){
$buscar=mysql_query("SELECT * FROM usuario WHERE email='$email' AND senha='$senha' LIMIT 1");
if(mysql_num_rows($buscar) == 1){
$dados=mysql_fetch_array($buscar);
$_SESSION["email"]= $dados["email"];
$_SESSION["senha"]= $dados["senha"];
setcookie("logado",1);
$log=1;
}
if(isset($log)){
$flash="Logado com sucesso";
}else{
if(empty($flash)){
$flash= "Digite seu e-mail e sua senha corretamente!"; //Se peço para retornar o $email ele retorna.
}
}
echo $flash;
}
} ?>
And the login.php
<?php
if($startaction == 1 && $acao == "logar"){
//Dados
$email= ($_POST["email"]);
$senha= sha1($_POST["senha"]); //$senha=addslashes(sha1($_POST["senha"]."ProjetoY"));
if(empty($email) || empty($senha)){
$msg="Preencha todos os campos!";
}else{
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
$msg="Digite seu e-mail corretamente!";
}else{
//Executa a busca pelo usuario
$login=new Login;
echo "<div class=\"flash\">";
$login=$login->logar($email, $senha);
echo"</div>";
}
}} ?>
And what can we do to help you, other than warn you that your code is vulnerable to attack?
– Maniero
Makes it vulnerable!!!
– Rodrigo Gomes
I know about vulnerabilities and I even have ideas to make a better security, but at first it’s just to show a login system. rs
– Yaazif
where is your connection to the bank?!
– Mastria
Dude this is college work, these days a guy came up with difficulty with that same code! hahaha
– Rogers Corrêa
Look what they are teaching in the faculties. It must be Systems Technology :P
– Rogers Corrêa
Password is not encrypted in the bank?
– Diego Vieira