<?php
session_start();
$letters=array("a","b","c");
$randomselect=rand(0,2);
$random=rand(10000000,90000000);
$text=$letters[$randomselect].$random;
$_SESSION["captcha"]=$text;
$pic=imagecreatetruecolor(100,30);
$backgroucolor=imagecolorallocate($pic,55,55,55);
$fontcolor=imagecolorallocate($pic,35,255,155);
imagefill($pic,0,0,$backgroucolor);
imagestring($pic,5,5,5,$text,$fontcolor);
header("Cache-Control:no-cache");
header("Content-type:image/png");
imagepng($pic);
imagedestroy($pic);
?>
---------------------------------------------------------------------------
<!-- index.php -->
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="dogrula.php" method="POST">
<table border="3">
<tr>
<td>
Please enter in the picture
</td>
<td>
<input type="text" name="captcha">
</td>
</tr>
<tr>
<td colpan="2">
<img src="captcha.php">
</td>
<td>
<input type="submit" name="submit" value="GIRIS">
</td>
</tr>
</table>
</body>
</html>
----------------------------------------------------------------------------------------------------
<!--dogrula.php-->
<?php
session_start();
if(isset($_REQUEST["captcha"] && $_REQUEST["captcha"]!=""
&& $_SESSION["captcha"]=$_REQUEST["captcha"]){
echo "TRUE";
}
else
echo "FALSE";
?>
Hiç yorum yok:
Yorum Gönder