I think it’s simple, just have a few images with code on, chosen at random. If the code field on the form doesn’t match the image, don’t send!
$error = 0;
$error = $error +1;
$message = $message."Please enter correct code";
if($error ==0 and $Submit=="Submit")
// submit post
//display message and form again