Necessary permissions to enable a captcha script?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jinxpk
Forum Newbie
Posts: 2
Joined: Tue Jan 16, 2007 2:27 pm

Necessary permissions to enable a captcha script?

Post by jinxpk »

Sorry if this is a newbie question but I've been trying to use a captcha script to thwart bots from using my form (testcaptcha: http://www.captcha.biz/captcha-explained.html). When I upload the script to another server with php it works fine, however my own server doesn't seem to allow it. Instead of showing the captcha image, a broken image box appears and it says the image cannot be shown because it contains errors. I assume this means my PHP is set up incorrectly, even though I use PHP on the site with no problems. Are there permissions that need to be set (like enabling image writing into the directory)? If so, where would I find these settings? Thanks.. Here is the code that the script uses--

Code: Select all

header("Content-type: image/png");

$image = imagecreate(60,20);

$background_color = ImageColorAllocate($image, rand(64,70), rand(70,73), rand(100,110));

$colour1 = ImageColorAllocate($image, rand(121,255), rand(126,255), rand(197,255));
$colour2 = ImageColorAllocate($image, rand(100,255), rand(120,255), rand(105,255));
$colour3 = ImageColorAllocate($image, rand(131,255), rand(137,255), rand(100,255));

imagestring($image,5,8,2,$_SESSION["captcha"],$colour1);
imagestring($image,5,8,2,$_SESSION["captcha"],$colour2);
imagestring($image,5,8,2,$_SESSION["captcha"],$colour3);

imageline($image, rand(1,300), rand(1,3), rand(10,150), rand(0,150), $colour1);
imageline($image, rand(1,300), rand(1,3), rand(10,150), rand(0,150), $colour2);
imageline($image, rand(1,300), rand(1,3), rand(10,150), rand(0,150), $colour3);

imageline($image, 10, 0, 14, 10, $colour1);
imageline($image, 20, 0, 24, 30, $colour2);
imageline($image, 55, 0, 34, 60, $colour3);

imagepng($image);

imagedestroy($image);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

comment out the header() line then directly call (in the browser) the file. It may be having errors.
jinxpk
Forum Newbie
Posts: 2
Joined: Tue Jan 16, 2007 2:27 pm

Post by jinxpk »

my php ini file was looking for the extensions in the wrong directory. THANKS!
Post Reply