What are the best practices for handling form submission and redirection in PHP?

When handling form submission and redirection in PHP, it is important to validate the form data, process it securely, and then redirect the user to a new page to display the result or a success message. To achieve this, you can use the header() function in PHP to redirect the user after processing the form data.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Validate and process form data
    // Redirect user to a new page
    header("Location: success.php");
    exit();
}
?>