Good afternoon, I'm creating a simple login and password system but I came across some strange errors, when I put the email and the password and I try to enter it it accuses me that the password is wrong, and I check the database the information is correct , I do not know why but here are two images for you to understand ...
the first image is the bank information ...
ThesecondimageandwhatishappeningatthetimeItrytoenter...
Myphpcode:
<?phpinclude("conexao.php");
if(isset($_POST['email']) && strlen($_POST['email']) > 0){
if(!isset($_SESSION))
session_start();
$_SESSION['email'] = $mysqli -> escape_string($_POST['email']);
$_SESSION['senha'] = md5(md5($_POST['senha']));
$sql_code = "SELECT senha, codigo FROM usuario WHERE email = '$_SESSION[email]'";
$sql_query = $mysqli -> query($sql_code) or die ($mysqli -> error);
$dado = $sql_query->fetch_assoc();
$total = $sql_query-> num_rows;
if($total == 0){
$erro[] = "Este email não pertence a nenhum usuário.";
}
else{
if($dado['senha'] == $_SESSION['senha']){
$_SESSION['usuario'] = $dado['codigo'];
} else{
$erro[] = "Senha incorreta.";
}
}
if(count($erro) == 0 || !isset($erro)){
echo "<script>alert('Login efetuado com sucesso... Seja bem vindo'); location.href='sucesso.php';</script>";
}
}
?>
<html>
<head></head>
<body>
<?php if(count($erro) > 0)
foreach($erro as $msg){
echo "<p>$msg</p>";
}
?>
<form method="POST" action="">
<input value="" type="text" placeholder="email" name="email">
<input type="password" name="senha">
<input type="submit" value="Entrar">
</form>
</body>
</html>
Someone could help me, I'm studying this part of php and with database ....