Usunięcie pomogło z errorem, ale kod literowy nie pojawia się, a obrazek czasem jest, a czasem nie.
skorzystałem z tego:
http://marusz.net/?txt=12includowany plik komentator.php
<?php
$status = "";
if ( isset ( $_POST["submit"] ) ) {
{
$status = "info";
}
else
{
$status = "error";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Test formularza zabezpieczonego captcha</title>
<meta name="author" content="JG24 TEAM - Marusz" />
<meta name="copyright" content="2009" />
<style type="text/css">
* { font-family: Arial, Verdana; font-size: 12px; }
input, textarea { display: block; padding: 3px; margin: 2px 0; border: 1px solid grey; }
form { padding: 15px; }
div#error { border: 2px solid #000; background-color: #ff0000; color: #fff; font-weight: bold; padding: 10px; }
div#info { border: 2px solid orange; background-color: yellow; color: #000; font-weight: bold; padding: 10px; }
</style>
</head>
<body>
<?php
if ( !empty ( $status ) ) {
?><div id="
<?php echo $status; ?>">
<?php echo $status == "info" ?
"Formularz został wysłany poprawnie" : "Wystąpił błąd - formularz nie zostanie wysłany..." ?></div>
<?php
}
?>
<form method="post">
Imię:
<input type="text" name="imie" value="
<?php if ( isset ( $_POST["imie"] ) && $status != "info" ) { echo htmlspecialchars($_POST["imie"]); } ?>" />
Tekst:
<br />
<textarea name="tekst">
<?php if ( isset ( $_POST["tekst"] ) && $status != "info" ) { echo htmlspecialchars($_POST["tekst"]); } ?></textarea>
<hr />
<img src="captcha.php" alt="captcha" />
<br />
Przepisz tekst z powyższego obrazka:
<input type="text" name="captcha" value="" />
<hr />
<input type="submit" name="submit" value="Wyślij formularz" />
</form>
</body>
</html>
captcha.php
<?php
/* config */
$imgPatch = "images-captcha/";
$fntPatch = "fonts/";
$images = preg_grep("/.+\..+/si", scandir
($imgPatch));
$fonts = preg_grep("/.+\..+/si", scandir
($fntPatch));
/* script */
$i = imagecreatefromjpeg($imgPatch . $images);
imagettftext
($i, 25
, rand(-7
, 7
), rand(1
, 20
), ceil(next(getimagesize($imgPatch . $images))/2
)+10
, imagecolorallocatealpha
($i, 255
, 255
, 255
, 60
), $fonts, $_SESSION["captcha"]);
header('Content-Type: image/jpeg'); imagejpeg($i);
imagedestroy($i);
?>