Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: need help w/captcha  (Read 5321 times)

0 Members and 1 Guest are viewing this topic.

12Strings

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    need help w/captcha
    « on: March 31, 2016, 06:23:02 PM »
    Quote
    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:

    Code: [Select]
    <?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; }
     }
    ?>
    [/b]

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: need help w/captcha
    « Reply #1 on: March 31, 2016, 09:23:34 PM »
    First:
    captcha
    https://en.wikipedia.org/wiki/CAPTCHA
    Quote
    "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge-response test used in computing to determine whether or not the user is human.
    Also:
    http://www.captcha.net/

    Rather than do it yourself, you can get an code thing from Google or others that lets you put a GOTCHA in your web page.

    Are you doing this inside of a specific application?