What are the potential pitfalls of relying solely on client-side validation to prevent multiple form submissions in PHP?

Relying solely on client-side validation to prevent multiple form submissions in PHP can be risky as it can easily be bypassed by users with technical knowledge. To prevent this, it is important to implement server-side validation as well. One way to prevent multiple form submissions is by generating a unique token on the server side and storing it in a session variable. This token is then included in the form as a hidden input field and validated upon form submission to ensure that it is unique.

<?php
session_start();

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!isset($_POST['token']) || $_POST['token'] !== $_SESSION['token']) {
        // Token mismatch, handle error or prevent form submission
    } else {
        // Process form submission
        // Generate new token
        $token = md5(uniqid(rand(), true));
        $_SESSION['token'] = $token;
    }
}

// Generate token and store in session
$token = md5(uniqid(rand(), true));
$_SESSION['token'] = $token;
?>

<form method="post" action="">
    <input type="hidden" name="token" value="<?php echo $token; ?>">
    <!-- Other form fields -->
    <button type="submit">Submit</button>
</form>