Google Like CAPTCHA with PHP.
Wall Script
Wall Script
Tuesday, July 06, 2010

Google Like CAPTCHA with PHP.

Are you looking for Google style CAPTCHA (Human verification code) script for PHP projects, Please take a look at this post. I want to explain how to implement cool-php-captcha script for forms. Use it and add security to your web projects.


Download Script     Live Demo

form.php
Contains HTML code image source captcha.php. File available in download script.
<form method="post"  action="reg.php">
<b>Name</b><br/>
<input type="text" name="name" /><br/>
<b>Message</b><br/>
<textarea name="message"></textarea><br/>
<img src="captcha.php" id="captcha" /><br/>
<a href="#" onclick="
document.getElementById('captcha').src='captcha.php?'+Math.random();
document.getElementById('captcha-form').focus();"
id="change-image">Not readable? Change text.</a><br/><br/>
<b>Human Test</b><br/>
<input type="text" name="captcha" id="captcha-form" /><br/&gt;
<input type="submit" />
</form>



reg.php
Contains PHP code
<?php
session_start();
if (!empty($_REQUEST['captcha']))
{

if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha'])
{
$note= 'Please enter correct text code';
}

else
{

if($_SERVER["REQUEST_METHOD"] == "POST")
{
$name=htmlentities($_POST['name']);
$message=htmlentities($_POST['message']);
// Insert SQL Statement
$note= 'Values Inserted Successfully';
}

}
unset($_SESSION['captcha']);
}
?>

Source code taken from : Cool-php-captcha
web notification

43 comments:

  1. So easy and so simple.
    "code is poetry"
    Thanks a lot for share

    ReplyDelete
  2. how far its security vise strong comparing with Recaptcha?

    ReplyDelete
  3. Hi Sri,

    very nice post :)

    you are so active writter :D

    ReplyDelete
  4. I love it! Thank you! Keep them comming!
    Can you make an example Youtube style Thumbs Up/Like script with ajax?

    ReplyDelete
  5. If the CAPTCHA is submitted incorrectly the form text boxes should still keep their POST values.

    ReplyDelete
  6. Hello,
    I am unable to downlaod from Box.net always use a mirror like Mediafire too. Its free and too good

    Thanks

    ReplyDelete
  7. very coool scripts thanks for share you ease my life :)

    ReplyDelete
  8. Thanks for easing my coding life, thanks for sharing, cools script!

    ReplyDelete
  9. Can U please write in APC (Alt. php cache )

    ReplyDelete
  10. I got an small problem, my image does not refresh when I click "Not readable? Change text." it just follows the # link... can you have an small look here http://video.zubeetube.com/video/ive3vXv-XRk/#sh_commenting

    ReplyDelete
  11. awesome tutorial, srinivas. Thanks for sharing

    ReplyDelete
  12. Why does the browser is not displaying an image. In Safari for example it displays a "?" where the image should be. I can't figure out what I'm doing wrong...

    ReplyDelete
  13. Excellent code again mate, have added you to our site:
    http://sitehelp.com.au/google-like-captcha-for-forms/

    Thumbs up :)

    ReplyDelete
  14. thank .... It's nice!

    ReplyDelete
  15. awesome job, keep it up :D

    ReplyDelete
  16. Hi srinivas i want a captcha for HTML page....is there any solution for this...through ajax

    ReplyDelete
  17. very nice and usable! Thank you!
    Can you make and save Ip address and word and time captcha create in Database?

    ReplyDelete
  18. Hey, nice script.

    I'm having some issues with it. It's working awesomely on my laptop with xampp, but when I am uploading the site to my fatcow server, the $_SESSION['captcha'] variable is turning out empty.

    Any pointers what needs to be tightened?

    Thanks again for making such an awesome tool!

    ReplyDelete
  19. It works fine in my local system...captcha image is not displaying on live server.......

    ReplyDelete
  20. Check for directory permissions and also check for gd2 extension.

    ReplyDelete
  21. Hello everyone,

    must say this lib is amazing, it creates really nice images,thank you author!

    but I also have two questions :)
    1) I somehow can't find the option of 'line through text'

    2) I am really missing the transparent option :(
    I was trying to implement it for few days here:

    http://scrp.at/7951c08735cb289025fc7f6c04f750b8ff41a86a

    It's 'probably' almost ready, but I can't figure out how to remove the red 'border' around the text :( It appears somewhere after 'WriteText' function, but I really can't figure out WHY....

    Basically it's original captcha class, just search for 'if($this->transparent)' to see what is changed to enable transparency...

    Example of transparent bg here: http://d.pr/B3M2 (green color comes from the background-color of html page)

    Thanks and waiting for a reply

    ReplyDelete
  22. That's code is good, but I have an essential questions:
    if a hacker knew that I got my code from this site, how is it possible for him/she to hack the words, especially that these words are coming from a fixed list!

    ReplyDelete
  23. Anyway that when the CAPTCHA form is blank that it also says "Please enter a correct value"? That would be helpful instead of it just looking like it sent the form through.

    ReplyDelete
  24. In case anyone still need the transparency, it's posted here: http://code.google.com/p/cool-php-captcha/issues/detail?id=14

    ReplyDelete
  25. its good captcha.
    but some problem with this its possible when i submit page and form value is deleted if captcha code is invalid.
    i want when use type invalid code then form value is not to be reset on only captcha value will be reset.
    so if u get it then reply me.....

    ReplyDelete
  26. i m not able to get the image in form ,i m using mozila firefox .what can be the problem .please reply me as soon as possible

    ReplyDelete
  27. Why do you name it Google Captcha?

    ReplyDelete
  28. thanks for sharing

    ReplyDelete
  29. Ran across this script and it works just fine. I am having a problem, however, in getting it to work in an existing $_SESSION-enabled environment. That is, using a slightly more secure technique I establish a "custom" session name and then include code for all routines to join this session. Problem is, I cannot seem to make captcha.php play nice and use the already existing session. Changing the $captcha->session_var to equal my special session name does not work. Any help would be surely appreciated. Thanks.

    ReplyDelete
  30. Nice work boss. can u make an example facebook timeline style cover photo with drag system?

    ReplyDelete
  31. Nice work boss. can u make an example facebook timeline style cover photo with drag system?

    ReplyDelete
  32. thanks for sharing :D

    ReplyDelete

mailxengine Youtueb channel
Make in India
X