Greeting, Have a basic register/login form and just used password_hash to store hashes in db. Having issue with checking login of the password
Tried not to overcook my brai :)
<?php
session_start();
require_once 'conn.php';
if(ISSET($_POST['login'])){
if($_POST['user_name'] != "" || $_POST['password'] != ""){
$username = $_POST['user_name'];
$password = $_POST['password'];
$sql = "SELECT * FROM `users` WHERE `user_name`=? AND `password`=? ";
$query = $conn->prepare($sql);
$query->execute(array($username,$password));
$row = $query->rowCount();
$fetch = $query->fetch();
if($row > 0) {
$_SESSION['user'] = $fetch['user_id'];
header("location: home.php");
} else{
echo "<script>alert('Detalii Incorecte'); window.location='login.php'</script>";
}
}else{
"<script>alert('Completeaza tot!'); window.location='login.php'</script>";
}
}
?>
OK what i am miissng here this works perfectly when i store plaintext... when i apply pasword_hash , i have diffcultie to "rewrite" my code to match hashed password fom column