...

View Full Version : my own captcha



Chris-2k
10-07-2012, 10:48 PM
hi

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


$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.';
}

Fou-Lu
10-07-2012, 11:59 PM
$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.

Chris-2k
10-08-2012, 01:04 AM
my captcha system isn't the normal. it is 20 jpg files hence the $captcha__answers var.

Fou-Lu
10-08-2012, 04:39 AM
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?

Chris-2k
10-08-2012, 07:38 PM
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:


if(!$_POST['captcha'] == $captcha_answers[0]

Fou-Lu
10-08-2012, 08:15 PM
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.

Chris-2k
10-08-2012, 10:24 PM
so this won't work............?

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

Fou-Lu
10-09-2012, 12:17 AM
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.

tangoforce
10-09-2012, 02:55 PM
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.uk/blog/php-captcha-security-images/

No jpeg files needed, no hard coding of the answers / codes, just follow the instructions here and be done with it :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum