What is the correct way to redirect a user to another page using PHP?

To redirect a user to another page using PHP, you can use the header() function with the Location parameter set to the URL of the page you want to redirect to. Make sure to call this function before any output is sent to the browser.

<?php
// Redirect to another page
header("Location: https://www.example.com/newpage.php");
exit;
?>