Hello i have a script for login and i'm using SHA512 for encryping pass. The thing is my script somehow doesnt fetch info with database table and i dont know why. My script returns "error_msg". Here is my code
<?php
session_start();
include ('engine/core/dbconfig.php');
$password=$_POST['password'];
$username=$_POST['username'];
if ($password='' or $username='') {
echo 'mandatory';
} else {
$stmt = $dbh->prepare("SELECT * FROM Admin_Local where Username=:username and Password=:hashed");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':hashed', $hash);
$hash = hash('sha512', $password);
$stmt->execute();
if ($row = $stmt->fetch()) {
$_SESSION['admin_local']=$row['ID_Admin'];
echo''.$_SESSION['admin_local'].'';
} else {
echo 'error_msg';
}
}