Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
A better captcha. - PHP Code Bank
A better captcha.
A captcha that is better than the one i made before.
<?php
/* Made by TheMasterSinner */
// start session
session_start();
// make image
$image = imagecreate(66, 26);
// define some colors
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
// set the background color to white
imagefill($image, 0, 0, $white);
/**************************************************
put some colored squares in the background
**************************************************/
// draw horizontal lines
for ($i=0; $i<=65; $i+=5) {
imageline($image, $i, 0, $i, 26, $black);
}
// draw vertical lines
for ($i=0; $i<=25; $i+=5) {
imageline($image, 0, $i, 66, $i, $black);
}
// fill in the squares with random colors
for ($x=3; $x<=25; $x+=5) {
for ($i=3; $i<=65; $i+=5) {
// make a random color
$rndColor = imagecolorallocate($image, rand(100, 150), rand(100, 150), rand(100, 150));
// fill in the square with the random color
imagefill($image, $i, $x, $rndColor);
}
}
/**************************************************
write a random string on the image
**************************************************/
//make a random string
$chars = str_shuffle('ABCDEHJMNX23456789');
$rndstr = substr($chars, 0, 6);
// set the session to the random string
$_SESSION['captcha'] = $rndstr;
// the string length
$strLen = strlen($rndstr);
// for each letter
for ($i=0; $i<$strLen; $i++) {
// make a random color
$rndColor = imagecolorallocate($image, rand(200, 240), rand(200, 240), rand(200, 240));
// put a letter on the image
imagestring($image, 5, (($i * 10) + 5), rand(0, 10), $rndstr{$i}, $rndColor);
}
// change the content type to a png image
header('Content-type: image/png');
// echo the image
imagepng($image);
// finished, so destroy the image
imagedestroy($image);
?>
Comments
Sorry but there are no comments to display