Having issues authenticating users on a sqlsrv/php login script, I'm pretty sure the user I'm trying do exist on the database but get the message user's not found. Here my 2 script to authenticate the user's login.
[Login.html]
<html>
<head>
</head>
<body>
<form name="log" action="log_action.php" method="post">
Username: <input class="form" type="text" name="uName"><br />
Password: <input class="form" type="password" name="uPass"><br />
<input name="submit" type="submit" value="Submit">
</form>
</body>
</html>
[log_action.php]
<?php
session_start();
ini_set('display_errors', 1);
error_reporting(~0);
include 'connect.php';
$uN = $_POST['uName'];
$uP = $_POST['uPass'];
$sql = "SELECT * FROM Person.lgn WHERE user_name = '".$uN."'";
$resultpwd = $conn->query($sql);
$rowpwd = $resultpwd->fetch(PDO::FETCH_ASSOC);
$hash_pwd = $rowpwd['user_pass'];
$hash = password_verify($uP,$hash_pwd);
if ($hash == 0){
echo 'ERROR LOGIN';
}else{
$query = "SELECT * FROM Person.lgn WHERE user_name = '".$uN."' AND user_pass = '".$hash_pwd."' ";
$result = $conn->query($query);
}
if(sqlsrv_has_rows($result) != 1){
echo "</br>";
echo "User not found or password is not correct";
}else{
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
echo $row['user_name'];
echo "</br>";
echo $row['user_pass'];
}
header("Location: list.php");
}
?>
EDITED But it doesn't work neither get somewhere an error!
This page isn’t working
pacificosrv is currently unable to handle this request.
HTTP ERROR 500