BostonDedicated
11-30-2006, 11:54 PM
Programmers,
What is the easiest way to add a captcha security image to a formmail page?
I've been searching around for a few days and can't find a good solution. Any help or suggestions would be appreciated.
Thanks!
computerwiz3491
12-30-2006, 11:19 PM
I actually wrote one a while back.
Save this file as capcha.php:
<?php
session_start();
header("Content-type: image/png");
$image = imagecreate(60,20);
$background_color = imagecolorallocate ($image, 219, 236, 255);
$green= imagecolorallocate($image, 25,255,0);
$blue = imagecolorallocate($image, 0, 90, 190);
imagestring($image,5,8,2,"$_SESSION[thecode]",$blue);
imagestring($image,5,8,2,"//\\//\\//\\//",$green);
imagepng($image);
imagedestroy($image);
?>
Then in your form:
srand((double)microtime()*1000000);
$rand = rand(0,999999999);
$thecode = substr(strtoupper(md5($rand)), 2, 5);
$thecode = str_replace("O", "A", $thecode);
$thecode = str_replace("0", "B", $thecode);
$_SESSION["thecode"] = $thecode;
print '<img class="ver_img" src="capcha.php" width="90" height="50" alt="Please enter the number from this image" /><input type="text" name="imagecode">';
Plexi_Hosting
12-31-2006, 12:14 AM
securimage from http://www.neoprogrammers.com/ is pretty easy to integrate
gigatux
12-31-2006, 10:54 AM
If you're using PHP, PhpCaptha is at http://www.ejeliot.com/pages/2 and I highly recommend it. It's released under the BSD license, is very easy to integrate (took me about 15 minutes) and is even customisable. I'm using it at http://www.twofo.co.uk/contact.php if you'd like to see it in action.
Cocodude
azizny
12-31-2006, 02:13 PM
I created/use this all the time:
http://www.phptricks.com/lesson.php?id=32
Peace,