Código PHP:
<?php
Function pass_gen($len=8){
$string = '';
$ok = false;
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for ($i = 0; $i < $len; $i++){
$pos = rand(0, strlen($chars)-1);
$string .= $chars{$pos};
}
return ($string);
}
Function captcha(){
header("Content-type: image/png");
$im = @imagecreate(100, 50) or die("Cannot Initialize new GD image stream");
$clave = pass_gen();
imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 5, 15, 15, $clave, $text_color);
imagepng($im);
imagedestroy($im);
return ($clave);
}
$c = captcha();
header("Content-type: text/html;");
echo $c;
echo 'No imprime nadaaa!!!!';
?>
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
Otra costia: como se supone que grabo esa imagen.... ? (si quisiera salvarla en disco)