How can the issue of a command being repeatedly executed when reloading the page be resolved in PHP?

Issue: The problem of a command being repeatedly executed when reloading the page can be resolved by using a technique called Post/Redirect/Get (PRG) pattern. This involves redirecting the user to a different URL after processing a form submission, which prevents the command from being resubmitted when the user refreshes the page.

// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data

    // Redirect to a different URL
    header("Location: success.php");
    exit();
}