Jump to content


Photo

Problem Implementing Captcha Chapter 11


  • Please log in to reply
No replies to this topic

#1 iron_man

iron_man

    New Member

  • Members
  • Pip
  • 2 posts
  • Gender:Male
  • Location:Gorakhpur

Posted 14 February 2015 - 09:18 AM

I typed in the code given below, hoped it would work, but despite much tinkering with code, I couldn't make it work. Can someone tell me my mistake
<?php
$pass_phrase='';
for($i=0;$i<=5;$i++)
$pass_phrase .=chr(rand(97,122));
define('CAPTCHA_WIDTH',100);
define('CAPTCHA_HEIGHT',25);
$img=imagecreatetruecolor(CAPTCHA_WIDTH,CAPTCHA_HEIGHT);
$bg_color=imagecolorallocate($img,255,255,255);
$text_color=imagecolorallocate($img,0,0,0);
$graphic_color=imagecolorallocate($img,64,64,64);
imagefilledrectangle($img,0,0,CAPTCHA_WIDTH,CAPTCHA_HEIGHT,$bg_color);
for($i=1;$i<=5;$i++)
{
imageline($img,0,rand() % CAPTCHA_HEIGHT,CAPTCHA_WIDTH,rand() % CAPTCHA_HEIGHT,$graphic_color);
}
for($i=1;$i<=50;$i++)
{
imagesetpixel($img,rand() % CAPTCHA_WIDTH,rand() % CAPTCHA_HEIGHT,$graphic_color);
}
imagettftext($img,18,0,5,CAPTCHA_HEIGHT-5,$text_color,"Courier New Bold.ttf",$pass_phrase);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users