Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Validate CAPTCHA

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
CMellor
Smarty Rookie


Joined: 22 Aug 2007
Posts: 8

PostPosted: Sat Oct 06, 2007 8:06 pm    Post subject: Validate CAPTCHA Reply with quote

Hey,

I'm using the Captcha plugin with Smarty, but I can't for the life of me work out how to validate it to check if the input is correct.

I though this might do it:

Code:

// Check if captcha matches
if(md5($_POST['captcha_confirm']) == $_POST['captcha']) {
   echo(1);
}
else {
   echo(0);
}

But it doesn't.

Any help on this is appreciated.
Back to top
View user's profile Send private message
XP_Prem
Smarty Regular


Joined: 22 Jul 2005
Posts: 37

PostPosted: Sun Oct 07, 2007 2:46 am    Post subject: Reply with quote

why md5?
Back to top
View user's profile Send private message Visit poster's website
CMellor
Smarty Rookie


Joined: 22 Aug 2007
Posts: 8

PostPosted: Sun Oct 07, 2007 4:31 pm    Post subject: Reply with quote

Why not? I assume to get the value of the hidden input, which is 32 characters in length, which is what is outputted when you md5 something, I'd have to md5 the value I typed in which matches the captcha code.

If I'm wrong, please correct me.
Back to top
View user's profile Send private message
CMellor
Smarty Rookie


Joined: 22 Aug 2007
Posts: 8

PostPosted: Sun Oct 07, 2007 5:53 pm    Post subject: Reply with quote

So yeah, I figured out there was a function that checks the codes, but that hasn't helped the situation. I tried this method:

Code:
// Assign CAPTCHA
define('CAPTCHA_SALT', 'blah');
// Check if captcha matches
if(validate_captcha($_POST['captcha'], $_POST['captcha_confirm'])) {
   echo 1;
}
else {
   echo 0;
}

But still nothing...

When I look at this function:

Code:
function validate_captcha($md5, $code){
   $shouldbe = md5($code . CAPTCHA_SALT . 'some salt' . $code .CAPTCHA_SALT . 'extra salt');
   return ($shouldbe == $md5);
}

I wonder if most of that $shouldbe variable is even necessary.
Back to top
View user's profile Send private message
pstamb
Smarty Rookie


Joined: 29 Jan 2007
Posts: 7

PostPosted: Sun Oct 07, 2007 7:46 pm    Post subject: Reply with quote

Please check the validate.php file in the zip file. There you will see how it's done.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP