What is the correct calculation for limiting guestbook entries to once every 10 minutes in PHP?

To limit guestbook entries to once every 10 minutes in PHP, we need to track the time of the last entry made by a guest and compare it with the current time. If the time elapsed is less than 10 minutes, we should prevent the guest from making another entry. We can achieve this by storing the timestamp of the last entry in a session variable and checking it before allowing a new entry.

session_start();

if(isset($_SESSION['last_entry_time']) && time() - $_SESSION['last_entry_time'] < 600) {
    echo "You can only post once every 10 minutes.";
} else {
    // Process the guestbook entry
    $_SESSION['last_entry_time'] = time();
    echo "Guestbook entry successfully submitted!";
}