image.php - generuje obrazek captcha
<? $result_captcha = mysql_query("SELECT * FROM captcha WHERE hash = '$_GET[hash]' AND code = '$_GET[code]'") or die (mysql_error()); $imgn = 'red.png'; $image = imagecreatefrompng($imgn); $red = imagecolorallocate($image, 70, 0, 0); $black = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 45, 15, 15, 110, $red, 'harrington.ttf', $get_captcha['code']); imagettftext($image, 10, 0, 140, 115, $black, 'arial.ttf', 'xxxl'); imagepng($image); imagedestroy($image); ?>
formularz.php - główny plik wyświetlający formularz + captcha
<? $result_captcha = mysql_query("SELECT hash, code FROM captcha ORDER BY RAND() LIMIT 1") or die (mysql_error()); ?> <form action="add.php" method="post"> <img width="256" height="120" src="http://southcraft.pl/image.php?hash=<?=$get_captcha['hash'] ?>"> <input type = "text" name="code"> <input type="hidden" name="hash" value="<?=$get_captcha['hash'] ?>"><br /> <input type="submit" class="input_submit" name="submit" value="Wyślij"/> </form>
Proszę o wytypowanie błędów i o poprawę kodu. Z góry dziękuje za pomoc.