How can PHP developers effectively use header redirection to address the issue of data duplication on page refresh?

When a user refreshes a page that was the result of a form submission, the data from the form can be resubmitted, causing duplication. One way to address this issue is by using header redirection after processing the form data. By redirecting the user to a different page after the form is processed, refreshing the page will not resubmit the form data.

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

    // Redirect to a different page to prevent form resubmission
    header("Location: success.php");
    exit;
}
?>