Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.174.2.3 diff -u -F^f -r1.174.2.3 form.inc --- includes/form.inc 29 Jan 2007 21:51:53 -0000 1.174.2.3 +++ includes/form.inc 15 Feb 2007 18:37:25 -0000 @@ -397,6 +397,13 @@ function drupal_validate_form($form_id, } } + if (!$form['#programmed'] && !empty($_SESSION['last_submitted']['hash'])) { + if ($_SESSION['last_submitted']['hash'] == md5(serialize($form))) { + // This is a repeat submission. + drupal_redirect_form(NULL, $_SESSION['last_submitted']['destination']); + } + } + _form_validate($form, $form_id); $validated_forms[$form_id] = TRUE; } @@ -432,6 +439,11 @@ function drupal_submit_form($form_id, $f } } } + + // Successful submit. Hash this form and store the hash in the session. + // We'll use this hash later whenever this user submits another form + // to make sure no identical forms get submitted twice. + $_SESSION['last_submitted'] = array('destination' => $goto, 'hash' => md5(serialize($form))); return $goto; }