How can the issue of opening the default page instead of the desired page be resolved in PHP?

Issue: The problem of opening the default page instead of the desired page in PHP can be resolved by ensuring that the correct URL is specified in the header() function to redirect to the desired page.

// Check if the condition is met to redirect to the desired page
if ($condition) {
    header("Location: desired_page.php");
    exit();
} else {
    header("Location: default_page.php");
    exit();
}