Using password_hash is the recommended way to store passwords. Don't separate them to DB and files.
Let's say we have the following input:
$password = $_POST['password']; I don't validate the input just for the sake of understanding the concept.
You first hash the password by doing this:
$hashed_password = password_hash($password, PASSWORD_DEFAULT); Then see the output:
var_dump($hashed_password); As you can see it's hashed. (I assume you did those steps).
Now you store this hashed_passwordhashed password in your database, ensuring your password column is large enough to hold the hashed value (at least 60 characters or longer). When a user asks to log them in, you check the password input with this hash value in the database, by doing this:
// Query the database for username and password // ... if(password_verify($password, $hashed_password)) { // If the password inputs matched the hashed password in the database // Do something, you know... log them in. } // Else, Redirect them back to the login page.