0
Good afternoon, I made a schedule to check if the login data is wrong or not, when I put the wrong data it gives me a alert
saying that the login or password is incorrect but when I click okay he looks like another alert
saying that I have successfully logged in and going to another page... what is happening?
code:
<html>
<head>
<script src="../js/angular.min.js"></script>
<script src="../js/jqueryAtualizado.js"></script>
<script src="../js/jqueryAtualizado.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<?php
include("conexao.php");
if(isset($_POST['senha']) && strlen($_POST['login']) > 0){
if(!isset($_SESSION))
session_start();
$_SESSION['login'] = $link -> escape_string($_POST['login']);
$_SESSION['senha'] = $_POST['senha'];
$sql_code = "SELECT senha, codigo FROM usuario WHERE login = '$_SESSION[login]'";
$sql_query = $link -> query($sql_code) or die ($link -> error);
$dado = $sql_query->fetch_assoc();
$total = $sql_query-> num_rows;
if($total == 0){
echo "<script>alert('Login ou a senha estão errados.');</script>";
}
else{
if($dado['senha'] == $_SESSION['senha']){
$_SESSION['usuario'] = $dado['login'];
}
}
if(count($total) != 0){
echo "<script>alert('Login efetuado com sucesso.'); location.href='../Adm/AdmAgenda.php';</script>";
}
}
?>
</body>
</html>
Thank you...
Wow, I liked gave a good shortened in the code... Thanks worked only that if I put any password it enters kkkkk
– Nathan
There is a typo in my code. Instead of _SESSION[password] it should be $password
– Wallace Maxters
was trying to put
'usuario'
– Nathan
I’m talking elseif check
– Wallace Maxters
Yes, I had seen that it was the same so I put
$dado['usuario'] == $_SESSION['senha']
and so he would, but he could put in any password he logged in– Nathan