November 6, 20178 yr A while back someone posted a script that checked how quickly a form was submitted. I thought I'd saved it in a safe place but obviously didn't as I can't find it. Anyone remember who it was and where they posted the code?
November 6, 20178 yr Author Yes, I thought it was him but I can't find the thread where he posted the code
November 6, 20178 yr It's this function ... <?php function spawnSecure($var) { $spawn = trim(stripslashes($var)); $now = date('Y-m-d H:i:s'); $diff = strtotime($now) - strtotime($spawn); if($diff<=1.5) { return false; } else { return true; } } ?> ... the difference here is 1.5 seconds, but this can be adjusted to your needs. All you need to do is add a form field ... <input type="hidden" name="anything" value="<?php echo date('Y-m-d H:i:s'); ?>"> ... then grab it when posted and check if it was too quick ... <?php if(!spawnSecure($_POST['anything'])) { $err_msg = "<b>Error!</b> - This appears to be an automated attempt, please take your time or call for assistance."; }
Create an account or sign in to comment