View Full Version : my own captcha

10-07-2012, 09:48 PM

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

10-07-2012, 10: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.

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

10-08-2012, 03: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?

10-08-2012, 06: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]

10-08-2012, 07: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.

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

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

10-08-2012, 11:17 PM
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.

10-09-2012, 01: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:


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