PHP Classes

captcha string

Recommend this page to a friend!

      Pure PHP CAPTCHA  >  All threads  >  captcha string  >  (Un) Subscribe thread alerts  
Subject:captcha string
Summary:best way to grab the string
Messages:2
Author:Bill Konz
Date:2014-09-11 19:40:48
 

  1. captcha string   Reply   Report abuse  
Picture of Bill Konz Bill Konz - 2014-09-11 19:40:48
Very nice class, thank you for sharing.

What is the best way to get the captcha string to match against the image text to see if they get it right when they type it into a text box?




  2. Re: captcha string   Reply   Report abuse  
Picture of Abius X Abius X - 2014-09-11 19:51:37 - In reply to message 1 from Bill Konz
I probably should add an example for that! Your question is very valid.
Please vote for the innovation award on PureTextRender package if you think this class is innovative (its just a wrapper around that, less than 50 lines!)

As seen in the example:

require_once __DIR__."/pure_captcha.php";
$k=new PureCaptcha();
$captchaToken=$k->show();


You just need to store $captchaToken variable in your session, probably by:
$_SESSION['captcha']=$captchaToken;


Then whenever you need to validate it, just check if it matches user input. Don't forget, whether it matches or not, you should invalidate it as every captcha should be only valid for one try. So :

if ($_SESSION['captcha']==$userInput)
//do stuff here

unset($_SESSION['captcha']);