Zanim założyłem nowy temat, sprawdziłem w Manualu i google, ale nie ma tam konkretnej odpowiedzi na moje pytanie. A tu są 2 pliki:
formularz.php
require("kod.php");
print("<html><head><meta http-equiv="Content
-Type
" content="text
/html
; charset
=iso
-8859-1" /></head>");
print("<title>Formularz - new user</title>");
print("<div id="div_g
"><table id="tabela_g
">"); print("<tr><td>kod</td><td><input type="text
" name="kod
" maxlength="10" size="10"/>");
//------------------------------------------------------------------------------------------------
draw();
print("</table></div></body></html>"); ?>
kod.php<?php header("Content-type: image/jpeg"); function draw() {
$string="abcdefghijklmnopqrstuvwxyz1234567890";
function draw_string($charset, $length) {
$length-=1;
$chars_amount=strlen($charset)-1; for ($i=0; $i<$length; $i++) {
$position=mt_rand(0
,$chars_amount); $new_string.=$charset[$position];
}
return $new_string;
}
$random_string=draw_string($string, 9);
$rysunek=imagecreate(100,20);
$kolor_bialy=imagecolorallocate($rysunek,255,255,255);
$kolor_losowy=imagecolorallocate
($rysunek,rand()%100
, rand()%256
, rand()%256
); $kolor_czarny=imagecolorallocate($rysunek,0,0,0);
imagefill($rysunek, 0,0,$kolor_czarny);
for($i=1; $i<=10; $i++) {
for ($n=1; $n<300; $n++) {
imagesetpixel
($rysunek, rand()%100
-1
, rand()%30
-1
, $kolor_losowy);} }
imagestring($rysunek,5,10,2,$random_string, $kolor_bialy);
imagejpeg($rysunek);
imagedestroy($rysunek);
}
?>
formularz.phpkod.php