@MehmetKS;

form sayfası;

<?php

	header("Content-Type: text/html; charset=UTF-8");
	session_start();

?><!DOCTYPE HTML>
<html>
	<body>
		<?php
			if(isset($_POST['guvenlikKodu']) && $_POST['guvenlikKodu'])
			{
				$guvenlikKontrol = false;
				
				if($_POST['guvenlikKodu'] == $_SESSION['guvenlikKodu'])
				{
					$guvenlikKontrol = true;
				}
				
				if($guvenlikKontrol)
				{
					echo 'Güvenlik resmi doğru!';
				}
				else
				{
					echo 'Güvenlik resmini yanlış girdiniz!';
				}
			}
		?>
		<br />
		<form method="POST">
			<label for="guvenlikKodu">Güvenlik Kodunu Giriniz: </label>
			<input type="text" name="guvenlikKodu" id="guvenlikKodu" required />
			<br />
			<img src="captcha.php" />
			<br />
			<input type="submit" value="Gönder" />
		</form>
	</body>
</html>
captcha.php
<?php
	
	session_start();
	
	$font = "arial.ttf";
	$width = "84";
	$height = "22";
	$hane = "6";
	
	function rastgele($text)
	{
		$mevcut = "abcdefghjkmnprstuxvyz23456789ABCDEFGHJKMNPRSTUXVYZ";
		$salla = "";
		
		for($i=0; $i < $text; $i++)
		{
			$salla .= $mevcut{rand(0,48)};
		}
		
		return $salla;
	}
	
	$metin = rastgele($hane);
	
	
	$resim_yaz = imagecreate($width, $height);
	imagecolorallocate($resim_yaz, 255, 255, 255);
	
	$text_renk = imagecolorallocate($resim_yaz, 255, 165, 0);
	$bg1 = imagecolorallocate($resim_yaz, 244, 244, 244);
	$bg2 = imagecolorallocate($resim_yaz, 227, 239, 253);
	$bg3 = imagecolorallocate($resim_yaz, 207, 244, 204);
	
	header("Content-type: image/png");
	imagettftext($resim_yaz, 26, -4, 4, 25, $bg1, $font, $metin);
	imagettftext($resim_yaz, 30, -7, 0, 15, $bg2, $font, $metin);
	
	for($i=0; $i < ($width*$height) / 400; $i++)
	{
		imageline($resim_yaz, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $bg3);
	}
	
	imagettftext($resim_yaz, 14, 3, 7, 17, $text_renk, $font, $metin);
	imagepng($resim_yaz);
	imagedestroy($resim_yaz);
	
	$_SESSION["guvenlikKodu"] = $metin;
captcha.php'nin olduğu dizinde arial.ttf dosyası olması gerekiyor.