Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: my own captcha

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    my own captcha

    hi

    please advise me how to do this, i need to check if $_POST['captcha'] contains an answer......

    PHP Code:
                    $captcha_answers = array(
                        
    'CaptchaSet1' => 
                        
    '3CBAJ''BXXSH''C4YY8''T3SBB''R9W3A''HNXMJ''6VUPE''PCYBT''59ESB''5D5YU'
                        
    'PB5TT''ECSNM''DDB65''MCT46''JDK3D''E9M4S''JVNR9''VNP4N''MJSPE''SJ43B''KYDNA'
                    
    );
                    
                    if(!
    $_POST['captcha'] == ???????)
                    {
                        
    $errors[] = '<div class="errors">Security captcha answer isn\'t correct.'
                    } 
    Last edited by Chris-2k; 10-08-2012 at 06:33 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    $captcha_answers is irrelevant. What matters is what you stored in your $_SESSION. The entered value should match the session stored value of what is printed on the image.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    my captcha system isn't the normal. it is 20 jpg files hence the $captcha__answers var.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by Chris-2k View Post
    my captcha system isn't the normal. it is 20 jpg files hence the $captcha__answers var.
    Okay, so how do you tell which one was displayed?

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    That's what i was asking m8, if u can help....?

    EDIT: not every1 is gonna guess captcha, only a bot. So the 21 ansswers in the array match the .jpg files, so could i do:

    PHP Code:
    if(!$_POST['captcha'] == $captcha_answers[0
    Last edited by Chris-2k; 10-08-2012 at 06:49 PM.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No, you'd use in_array with $captcha_answers['CaptchaSet1']. But that doesn't verify the one chosen to the value typed. For that you need to store it in a session or persist it in another fashion for lookup.

  • #7
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    so this won't work............?

    can u suggest me how to work it, using my jpg files...............?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You use a session. You need to persist the provided data in order to verify it after. You can use any type of persistent storage you want so long as it isn't client controlled (such as cookies).
    Generate the text > store it > create the graphics. Then when receiving the form submission, check the stored text to the entered text. If it matches, the captcha was answered properly.

  • #9
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,345
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Quote Originally Posted by Chris-2k View Post
    my captcha system isn't the normal. it is 20 jpg files hence the $captcha__answers var.
    Why are you doing that? - If its because you don't know how to do it dynamically then just use the white hat web design version which is pretty easy to understand:

    http://www.white-hat-web-design.co.u...curity-images/

    No jpeg files needed, no hard coding of the answers / codes, just follow the instructions here and be done with it
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •