What is the best practice for handling password verification in PHP, especially when redirecting to another page upon successful entry?

When handling password verification in PHP, it is best practice to use secure hashing algorithms like bcrypt to securely store and compare passwords. Upon successful password verification, you can redirect the user to another page using header("Location: new_page.php") to maintain a secure and seamless user experience.

<?php

// Retrieve the user's stored hashed password from the database
$stored_password = "hashed_password_from_database";

// Verify the entered password using password_verify function
if (password_verify($_POST['password'], $stored_password)) {
    // Password is correct, redirect to new page
    header("Location: new_page.php");
    exit;
} else {
    // Password is incorrect, display error message
    echo "Incorrect password";
}

?>