Function.check form key

check_form_key -- Check the form key.

Description
This function is used to check a given form key which was generated with the add_form_key function.
 * 1) boolean check_form_key (string $form_name, [int $timespan = false], [string $return_page = ''], [bool $trigger = false])
 * Note: This check is required for all actions which alter the database and are not already secured by confirm_box !

Examples
All these examples use the form_name that is set in the first example in the add_form_token article!

Example #1 Only check
If you only want to check whether the submitted form is valid you'll must do the error triggering in the php code. if (!check_form_key($form_key)) {  trigger_error($user->lang['FORM_INVALID']); }

Example #2 Time limit
With this function you have the possibility to force a user to submit a form within a x number of seconds. To do this you'll have to pass the second parameter. // Give the user 30 seconds to finish this form if (!check_form_key($form_key, 30)) {  trigger_error($user->lang['FORM_INVALID']); }

Example #3 Trigger error
To let the function trigger the error when the check fails you must set the fourth parameter to true. check_form_key($form_key, false, '', true);