This is the tutorial that can implement the captcha in the PHP form and verify the user which is a real user or any robot users. so just make the below files and set to your form which can attach the captcha.
Step 1)
Make php file and put the below code there.
<div>
<img src="captcha_code.php"/>
<input name="captcha_code" type="text" id="captcha_code" placeholder="Enter Captcha Code">
</div>
Step 2)
Make another file name “captcha_code.php”. put the below code in that file.
<?php
session_start();
$random_alpha = md5(rand());
$captcha_code = substr($random_alpha, 0, 6);
$_SESSION["captcha_code"] = $captcha_code;
$target_layer = imagecreatetruecolor(70,30);
$captcha_background = imagecolorallocate($target_layer, 148, 7, 10);
imagefill($target_layer,0,0,$captcha_background);
$captcha_text_color = imagecolorallocate($target_layer, 255, 255, 255);
imagestring($target_layer, 8, 8, 8, $captcha_code, $captcha_text_color);
header("Content-type: image/jpeg");
imagejpeg($target_layer);
?>
Step 3)
Now visit your form it will display the captcha code in your form.