What role does the use of header() function play in preventing unwanted value deductions in PHP form submissions?

When submitting a form in PHP, it is important to prevent users from resubmitting the form accidentally or maliciously, which could lead to unwanted value deductions or duplicate entries. One way to prevent this is by using the `header()` function to redirect users to a different page after the form has been successfully submitted. This way, if the user tries to refresh the page or navigate back to the form submission page, they will be redirected to a different page, preventing the form from being submitted again.

// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data
    
    // Redirect user to a different page to prevent resubmission
    header("Location: success.php");
    exit();
}