Are there any best practices for handling form submissions in PHP to avoid the need for multiple clicks on the submit button?

When handling form submissions in PHP, one common issue is the need for multiple clicks on the submit button due to page refreshes or resubmissions. To avoid this, one best practice is to use a POST-redirect-GET pattern. After processing the form data, redirect the user to a new page using the header() function. This way, if the user refreshes the page, the form data will not be resubmitted.

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