Kod php:
<?
//wyswietlanie tokena <img src="token.php" alt="token" style="vertical-align: middle" />
session_start();
$pool = '23456789'; //liczby z których bedziemy losować token
$img_width = 100; //wymiary tokena
$img_height = 16;
$str = ''; //wyzerowanie tokena
for ($i = 0; $i < 5; $i++){ // losowanie liczb
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
$string = $str;
$_SESSION['captcha'] = $string; //tworzymy sesje z wartością tokena
$im = imagecreate($img_width, $img_height); //tworzymy obrazek
$bg_color = imagecolorallocate($im,255,255,255); // kolor tła
$font_color = imagecolorallocate($im,0,0,0); // kolor czcionki
$grid_color = imagecolorallocate($im,246,246,246); // kolor lini
$border_color = imagecolorallocate ($im, 246, 246, 246); // kolor ramki
// Tworzenie tokena
imagefill($im,1,1,$bg_color);
ImageLine($im,90,0,90,30,$grid_color); //1
ImageLine($im,10,0,10,30,$grid_color); //2
ImageLine($im,20,0,20,30,$grid_color); //1
ImageLine($im,30,0,30,30,$grid_color); //1
ImageLine($im,40,0,40,30,$grid_color); //1
ImageLine($im,50,0,50,30,$grid_color); //1
ImageLine($im,60,0,60,30,$grid_color); //1
ImageLine($im,70,0,70,30,$grid_color); //1
ImageLine($im,80,0,80,30,$grid_color); //1
ImageLine($im,0,5,100,5,$grid_color); //1
ImageLine($im,0,10,100,10,$grid_color); //1
ImageLine($im,0,15,100,15,$grid_color); //1
$x = rand(5, $img_width/(7/2)); // pozycja liczb w tokenie
imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
for($a=0; $a < 7; $a++){
imagestring($im, 3, $x, 1, substr($string, $a, 1), $font_color);
$x += (5*2); #odstęp
}
header("Content-type: image/gif");
imagegif($im);
imagedestroy($im);
?>
Ale mam problem jak zrobić by w rejestracji pojawiło się pole z przepisaniem tego tokena i sprawdzało czy jest on zgodny z podanym na obrazku.
Zakładki