How can a reload lock be implemented in a guestbook to prevent duplicate entries in PHP?

To prevent duplicate entries in a guestbook, a reload lock can be implemented by setting a session variable upon form submission and checking this variable before allowing the form to be submitted again. This ensures that the form can only be submitted once per session, preventing duplicate entries.

<?php
session_start();

if(isset($_POST['submit'])) {
    if(!isset($_SESSION['form_submitted'])) {
        // Process form submission
        $_SESSION['form_submitted'] = true;
    } else {
        echo "Form already submitted!";
    }
}
?>