
<?php
session_start(); // plaats deze code aan het begin van je document (gew. 21-3-2005)

function prevent_multi_submit($type = "post") { // use "get" if this is your form method

    $string = "";
    $posted_array = ($type == "get") ? $_GET : $_POST;
    foreach ($posted_array as $val) {
        $string .= $val;
    }
    if (isset($_SESSION['last'])) {
        if ($_SESSION['last'] === md5($string)) {
            return false;
        } else {
            $_SESSION['last'] = md5($string);
            return true;
        }
    } else {
        $_SESSION['last'] = md5($string);
        return true;
    }
}
/* example of use:
if (isset($_POST)) {
    if ($_POST['field'] != "" && strlen < 25) { // place here the form validation and other controls
        if (prevent_multi_submit()) { // use the function before you call the database
            mysql_query("INSERT INTO tabel..."); // or send a mail like...
            mail($mailto, $sub, $body);
        } else {
            echo "The form is already processed";
        }
    } else {
        // your error about invalid fiels
    }
} */
?> 
 