Hello all,
I was asked to add a captcha to a form on a website that I'm updating. You can see it here:
http://www.sipesandson.com/enquiries.php
I am not good at hardcoding so I'm kind lost. I did some research and I think I need to use this code called OpenCaptcha.
http://opencaptcha.com/#common
The code sounds easy enough but I have no clue how to install it into my original code.
Here's the directions:
On the form page, dynamically create a filename (http://www.opencaptcha.com/img/{random}.jpgx and print to the screen both an >img< and an >input value={image name}< tag including that name
Tips
Use the current timestamp and your domain name as the random number { 200705041231mydomainname.jpgx }
Add -{height}-{width} to specify the size { 200705041231mydomainname-80-240.jpgx will make a 80px tall and 240px wide image }
On the form page, add a text field for the user to enter the Captcha code
On the processing page, check to see if http://www.opencaptcha.com/validate.php?img={imageName}&ans={users Answer} returns the word "pass" or "fail"
Below is a really simple sample PHP code.
Can someone explain this: On the form page, dynamically create a filename (http://www.opencaptcha.com/img/{random}.jpgx and print to the screen both an >img< and an >input value={image name}< tag including that name ?
Here's their example code:
Login Page
Processing Page<?
if($_GET['opencaptcha']=='failed') { echo "<script>alert('You Did Not Fill In The Security Code Correctly');</script>";}
$date = date("Ymd");
$rand = rand(0,9999999999999);
$height = "80";
$width = "240";
$img = "$date$rand-$height-$width.jpgx";
echo "<input type='hidden' name='img' value='$img'>";
echo "<a href='http://www.opencaptcha.com'><img src='http://www.opencaptcha.com/img/$img' height='$height' alt='captcha' width='$width' border='0' /></a><br />";
echo "<input type=text name=code value='Enter The Code' size='35' />";
?>
<?
if(file_get_contents("http://www.opencaptcha.com/validate.php?ans=".$_POST['code']."&img=".$_POST['img'])=='pass') {
// CONTINUE LOGIN
} else {
header("LOCATION: ".$_SERVER['HTTP_REFERER']."?opencaptcha=failed");
}
?>
I was going to pay someone to do this for me but I'd really like to learn how to do this myself. Thanks for reading.


Reply With Quote






Bookmarks