Wednesday, December 1, 2010

Re: Problem with Math Captcha component @ 1.3.6

On Tue, Nov 30, 2010 at 7:07 PM, Salines <nikola.paradzik@gmail.com> wrote:
> I focused on this function:
>
> function validate($data) {
>        if ($data == $this->Session->read('MathCaptcha.answer')){
>        return true;
>        }
>    }
>
> $data exists
> $this->Session->read('MathCaptcha.answer')  exists
>
>
> Why this function does not return 'true' when called from controller
> with the following code
>
> if ($this->MathCaptcha->validate($this->data['Contact']
> ['security_code'])) {
> ------
> }
>
> $this->data['Contact']['security_code'] exists

They may exist, but are they equivalent? Try:

function validate($data)
{
debug($data);
debug($this->Session->read('MathCaptcha.answer'));

if ($data == $this->Session->read('MathCaptcha.answer')){
return true;
}
}

As an aside, I recommend you swap the two validations in your code.
Validate Contact first, then the captcha. The reason is that, if
Contact doesn't validate there's no point in the captcha validating
because it will have to be filled in again anyway.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: