What best practices should be followed when refreshing the page using header() in PHP?

When refreshing a page using header() in PHP, it is important to prevent the browser from resubmitting form data by redirecting to the same page without any POST data. This can be achieved by using the header() function to redirect to the same page with a GET request. Additionally, it is recommended to use the exit() function after the header() function to prevent any further code execution.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Process form data
    
    // Redirect to the same page with a GET request
    header("Location: ".$_SERVER['PHP_SELF']);
    exit();
}
?>