Tak teraz mam problem s captchov. Nejde mi zobrazit obrazok. Kde je chyba?
Captcha.php
Kód: Vybrať všetko
<?php
session_start();
header('Content-type: image/png');
$im = imagecreatetruecolor(340, 70);
$white = imagecolorallocate($im, 100, 100, 100);
$grey = imagecolorallocate($im, 155, 155, 155);
$grey1 = imagecolorallocate($im, 051, 204, 051);
$black = imagecolorallocate($im, 255, 255, 000);
imagefilledrectangle($im, 0, 0, 399, 70, $white);
function nahodny_text ()
{
$moznosti= array("1","2","3","4","5","6","7","8","9",
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","R","S","T","U","V","W","Y","Z");
$mista="8";
$heslo="";
for ($i=0 ;$i<=$mista-1 ;$i++)
{
$nahoda=rand(0, count($moznosti)-1);
$heslo.=$moznosti[$nahoda];
}
return $heslo;
}
$text = nahodny_text();
$_SESSION['captcha'] = $text;
$text_oklamanie = nahodny_text();
$text_oklamanie_2 = nahodny_text();
$font = 'pismo.ttf';
$font1 = 'pismo1.ttf';
imagettftext($im, 50, 10, 31, 35, $grey, $font, $text_oklamanie);
imagettftext($im, 50, -10, -31, 35, $grey1, $font, $text_oklamanie_2);
imagettftext($im, 50, 0, 10, 50, $black, $font1, $text);
imagepng($im);
imagedestroy($im);
?>Kód: Vybrať všetko
<iframe id="myframe" src="captcha.php" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none" name="myframe"></iframe>
<a href="captcha.php" target="myframe">Refresh obrázka</a>
<br>Opíšte žltý text z obrázku.
<br><font color="red"><strong>POZOR:</strong></font>Text neobsahuje nulu!
<br>Systém je citlivý na veľkosť písmen!<br>
<form method="post" action="">
<input type="text" name="captcha">
<input type="submit" value="OK">
</form>
<?
session_start();
if (isset($_POST['captcha'])){
if ($_POST['captcha']==$_SESSION['captcha']){
echo "Váš kód bol správny";
}else {
echo "Váš kód nebol správny";
}
}
?>