This script generates images (known as "Captcha's") which contain security codes used for protecting a form from spam bots. This scripts works well and can be implemented into any php page, with very little php knowledge.
Please see code below:
Place the following code on your form. This will generate an image with a random string of characters along with the text field where the user will retype the code.
<img src="CaptchaSecurityImages.php" />
Security Code:
<input id="security_code" name="security_code" type="text" />
You can also specify certain options for the image by passing them as variables to CaptchaSecurityImages.php. The options available are the width and height of the image and the number of characters
<img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt="captcha" />
<input id="security_code" name="security_code" type="text" />
Then please also download the attachment and Place the following in the code where the form is submitted to. This code will check what the user has typed matches the code in the image.
<?php
session_start();
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
unset($_SESSION['security_code']);
} else {
// Insert your code for showing an error message here
}
?>
Please post if you get stuck. and don't forget to download the attachment and place it in your root directory.
Best of luck