What is the best practice for reloading a form page in PHP after submitting data?

After submitting data in a form page, the best practice for reloading the page in PHP is to use the header() function to redirect back to the same page. This ensures that the form data is not resubmitted if the user refreshes the page, preventing duplicate form submissions.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Process form data here
    
    // Redirect back to the form page to prevent resubmission
    header("Location: {$_SERVER['PHP_SELF']}");
    exit;
}
?>