Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

need help with this Captcha


  • Please log in to reply
No replies to this topic

#1 12Strings

12Strings

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:04:14 PM

Posted 31 March 2016 - 05:52 PM

I need help with this Captcha code. when I try it, all I get is code,
starting with

 "captcha_varname='$captcha_var_name';" through "?>"

 It's like my Php wasn't working but I've confirmed it is.  I'm hoping

someone will tell me why. Following is my code COPIED FROM ONLINE:

<?PHP
// simple-captcha.php
class FGSimpleCaptcha extends FG_CaptchaHandler;
 {
    var $error_str;
    var $captcha_varname;
    var $uniquekey;

    function FGSimpleCaptcha($captcha_var_name)
 {
        $this->captcha_varname='$captcha_var_name'; // ?

        $this->uniquekey='abc12fghijkl34mno;
        }
    /*Add more simple questions here.*/
    function GetSimpleCaptcha()
 {
        $arrQuestions = array(
"Which of sock, library, cake or red is a color? "=>"red",
"Enter the number thirteen thousand three hundred and sixty eight in

digits: "=>"13,368");       
       
        $question = array_rand($arrQuestions);
        $answer = $arrQuestions[$question];

        $_SESSION['FGCF_Captcha_Answer'] = $this->Md5CaptchaAnswer

($answer);

     return $question;
 }
    function SetFormKey($key)
    { $this->uniquekey = $key; }
    function GetKey()
    { return $this->uniquekey; }
    function Validate()
 {
        $ret=false;
        if(empty($_POST[$this->captcha_varname]))
 {
            $this->error_str = "Please answer the anti-spam question";
            $ret = false;
 }
        else
 {

            $scaptcha = trim($_POST[$this->captcha_varname]);

            $scaptcha = strtolower($scaptcha);

            $user_answer = $this->Md5CaptchaAnswer($scaptcha);

            if($user_answer != $_SESSION['FGCF_Captcha_Answer'])
 {
                $this->error_str = "Failed the anti-spam check!";
                $ret = false;
 }
            else
            { $ret = true; }
 }
//else
        return $ret;
 }
    function Md5CaptchaAnswer($answer)
 { return md5($this->GetKey().$answer); }
    function GetError()
    { return $this->error_str; }
 }
?>



BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users