How can PHP developers prevent automatic form submissions upon page load?

To prevent automatic form submissions upon page load, PHP developers can use a hidden input field with a unique value that is submitted with the form. This value can be checked on the server-side to verify if the form was submitted intentionally by a user or automatically upon page load.

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['submit']) && $_POST['hidden_field'] === 'unique_value') {
        // Form was intentionally submitted by a user
        // Process form data here
    } else {
        // Form submission was automatic, ignore or handle accordingly
    }
}
?>

<form method="post" action="">
    <input type="hidden" name="hidden_field" value="unique_value">
    <button type="submit" name="submit">Submit Form</button>
</form>