note 90673 deleted from book.mail by danbrown
| From: | danbrown@php.net | Date: | Mon, 04 May 2009 12:56:32 +0000 |
| Subject: | note 90673 deleted from book.mail by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154182@lists.php.net to get a copy of this message | ||
Note Submitter: rajeshrajesh dot 35 at gmail dot com
----
<?php
session_start();
function generateCode($characters) {
// list all possible characters, similar looking characters and vowels have been removed
$possible = '23456789abdfghjkmnpqrstvwxyzABDEFGHJLMNPQRST';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-5), 1);
$i++;
}
return $code;
}
$im = @imagecreatefromjpeg("image/captcha.jpg");
$rand = generateCode(4);
$_SESSION['captcha'] = $rand;
$text_color = imagecolorallocate($im, 205, 250, 205);
imageline ($im,$x1,$y1,$x2,$y2,$text_color);
imagestring($im, 5, 2, 2," ".$rand, $text_color);
header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
imagedestroy($im);
?>