I just made a 'cheap captcha' script that asks for the sum of two random numbers...you could use it if you like.
Put this in your form:
PHP Code:
<?php $randomNumber1 = rand(1, 10); $randomNumber2 = rand(1, 10); $sum = $randomNumber1 + $randomNumber2; $_SESSION['sum'] = $sum; ?> <p class="label">We just need to check to make sure you're not a Dalek. Please add the numbers below and enter in the result.</p> <label for="captcha" class="label"><?php echo $randomNumber1.' + '.$randomNumber2.' = '; ?></label> <input type="text" class="input" id="captcha" name="captcha" />
And this in your validation:
PHP Code:
if (empty($_POST['captcha'])){ $errors[] = "You must enter a number to answer the math question below."; } else if ($_POST['captcha'] != $_SESSION['sum']){ $errors[] = "The number you entered wasn't the right answer for the math question."; }
I use $errors as an array that will prevent the script from executing if it has a value.
__________________ Want new web resources every day? - Follow me on Please login or register to view this content. Registration is FREE