How can a successful login in PHP be followed by a redirect to another page?

After a successful login in PHP, you can redirect the user to another page by using the header() function to send a raw HTTP header to the browser. You can set the "Location" header to the URL of the page you want to redirect to. Make sure to call the header() function before any output is sent to the browser to avoid any errors.

// Check if login is successful
if ($login_successful) {
    // Redirect to the desired page
    header("Location: another_page.php");
    exit; // Make sure to stop the script execution after the redirect
}