Add captcha to php form I have

Hi, I use a very basic PHP contact form, simple place text fields on the page with the form and then link to enquiry.php which has this code…

$my_email = "";
$continue = "/";
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Build message.
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = stripslashes($message);
$subject = "General Enquiry";
$subject = stripslashes($subject);
$from_Name = "";
if(isset($_REQUEST['Name']) && !empty($_REQUEST['Name'])){$from_Name = stripslashes($_REQUEST['Name']);}
$headers = "From: {$from_Name} <{$_REQUEST['Email']}>";
$message = "Thank you for your enquiry. We will be in touch with you as soon as possible.
Website Name";
$subject = "General Enquiry";
$headers = "From: Website Name <>";

I want to add a captcha to this. - I found a place with a verificationimage.php which generates 4 random number images.

// ----------------------------------------- 
//  The Web Help .com
// ----------------------------------------- 

header('Content-type: image/jpeg');

$width = 50;
$height = 24;

$my_image = imagecreatetruecolor($width, $height);

imagefill($my_image, 0, 0, 0xFFFFFF);

// add noise
for ($c = 0; $c < 40; $c++){
	$x = rand(0,$width-1);
	$y = rand(0,$height-1);
	imagesetpixel($my_image, $x, $y, 0x000000);

$x = rand(1,10);
$y = rand(1,10);

$rand_string = rand(1000,9999);
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);



How would I implement the captcha to the form? Any suggestions or tips would be much appreciated.

Thanking you :slight_smile:

I have one written by myself. Can you please to implement this one?

Download and see the example. If you want more help then ask here.

Thanks for the reply. I will try it out and let you know how I get on.