How can PHP be used to redirect users to a previous page upon clicking "OK" in a pop-up window displaying an error message?

When a user clicks "OK" in a pop-up window displaying an error message, you can use PHP to redirect them back to the previous page. This can be achieved by using the `header()` function in PHP to send a redirect header to the browser. By setting the `Location` header to `$_SERVER['HTTP_REFERER']`, the browser will automatically redirect the user to the previous page.

<?php
if(isset($_POST['submit'])) {
    // Display error message in pop-up window
    echo "<script>alert('Error message here');</script>";
    
    // Redirect user to previous page
    header("Location: {$_SERVER['HTTP_REFERER']}");
    exit;
}
?>