How can unwanted data transmission be prevented when reloading a page in PHP?

Unwanted data transmission when reloading a page in PHP can be prevented by using the Post/Redirect/Get (PRG) pattern. This involves processing form submissions using POST requests, then redirecting to a new page using a GET request to prevent form resubmission on page reload.

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