Security Image, CAPTCHA [solved]
Moderator: General Moderators
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Security Image, CAPTCHA [solved]
So I have a file called image.php, where the CAPTCHA is generated. Now my problem is how to communicate between image.php and the actual page. The CATCHA "code" is stored in the database or in $_SESSIONS a variable. But when I tired to run a MySQL query in the image.php file it doesn’t work, I could be doing something wrong.
Last edited by anthony88guy on Wed Mar 15, 2006 9:37 pm, edited 1 time in total.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
image.php:
Code: Select all
<?php
header("Content-type: image/png");
$image['height'] = 20;
$image['width'] = 65;
$img = imagecreate($image['width'], $image['height']);
$image['bordercolor'] = imagecolorallocate($img, 102, 102, 102);
$image['borderwidth'] = 2;
$image['bgcolor'] = imagecolorallocate($img, 85, 85, 85);
$image['textcolor'] = imagecolorallocate($img, 204, 204, 204);
$image['textsize'] = 10;
$image['textangle'] = rand(-7,7);
$image['text'] = substr(md5(rand(1,1000)),27); //stored in sessions var and/or database
imagefill($img, 0, 0, $image['bordercolor']);
imagefilledrectangle($img, $image['borderwidth'], $image['borderwidth'], $image['width']-$image['borderwidth'], $image['height']-$image['borderwidth'], $image['bgcolor']);
imagettftext ($img, $image['textsize'], $image['textangle'], rand(5,20), 15, $image['textcolor'], '/fonts/tahomabd.ttf', $image['text']);
imagepng($img);
?>-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm