What is the best practice for handling a redirect to another page after a successful form submission in PHP?

After a successful form submission in PHP, it is best practice to redirect the user to another page to prevent form resubmission on page refresh. This can be achieved by using the header() function in PHP to send a Location header with the URL of the page to redirect to.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data

    // Redirect to another page after successful form submission
    header("Location: success.php");
    exit();
}
?>