I am sorry.. I was able to make the validation worked again.
if (empty($this->data))
{
$this->render();
}
else
{
if ($this->Email->save($this->data))
{
if
($this->Captcha->check($this->data['Email']['userCode'])) {
// Flash that it has been sent
$this->flash('Your email has been
sent.','/emails');
} // end: if
($this->Captcha->check($this->data['Email']
['userCode'])) {
} // end: if ($this->Email->save($this->data))
else
{
$this->set('errorMessage', 'Please correct
errors below.');
$this->render();
}
} // end: if (empty($this->data))
Although, how do you add error if the captcha is wrong? Right now,
what he is doing is just refreshing on the page. Without the error
that the captcha is wrong.
Obviusly, i would just do..
if ($this->Captcha->check($this->data['Email']['userCode'])) {
// Flash that it has been sent
$this->flash('Your email has been sent.','/emails');
} // end: if ($this->Captcha->check($this->data['Email']['userCode']))
{
else
{
// add the error here? but how to place/show again on the template?
}
How would i place the error back on the template?
On Jul 26, 12:40 pm, Louie Miranda <[EMAIL PROTECTED]> wrote:
> Yes. My index() function is my form and also my validation for the
> captcha.
> I have tried to add this code..
>
> function index()
> {
>
> print_r($this->data);
> //echo $_SESSION[CAPTCHA_SESSION_ID]."///";
> //Array ( [Email] => Array ( [name] => sdfgsdfs [message] =>
> sdfsdfsfsdsdf ) )
>
> $client_name = $this->data['Email']['name'];
> $client_message = $this->data['Email']['message'];
> $client_userCode = $this->data['Email']['userCode'];
>
> if (!empty($this->data))
> {
> //$this->render();
> if
> ($this->Captcha->check($this->data['Email']['userCode'])) {
>
> if ($this->Email->save($this->data))
> {
> // Flash that it has been sent
> $this->flash('Your email has been
> sent.','/emails');
>
> } // end: if ($this->Email->save($this->data))
>
> } // end: if
> ($this->Captcha->check($this->data['Email']
> ['userCode'])) {
> else
> {
> $this->render();
> }
>
> } // end: if (empty($this->data))
>
> } // end of function sent
>
> If data is !empty, process what i wish. Else, $this->render();
> I have deleted the redirection, and its not being redirected once the
> form is not yet filled-up.
>
> Although, my next problem is the validation error. Which i placed
> before and have tested.
> <label>Name:</label>
> <?php echo $html->input('Email/name', array('class' => 'input',
> 'style' => 'width: 200px;')); ?>
> <?php echo $html->tagErrorMsg('Email/name', 'Name is required.'); ?>
> <label>Message:</label>
> <?php echo $html->textarea('Email/message', array('rows'=>'10',
> 'cols'=>'40')); ?>
> <?php echo $html->tagErrorMsg('Email/message', 'Message is
> required.'); ?>
>
> <label>Captcha:</label>
> <?php echo $html->input('Email/userCode', array('class' => 'input',
> 'style' => 'width: 200px;')); ?>
> <?php echo $html->tagErrorMsg('Email/userCode', 'Captcha is
> required.'); ?>
>
> Is not working anymore, what could i be missing? BTW, i also have
> models/email.php with
> var $validate = array(
> 'name' => VALID_NOT_EMPTY,
> 'message' => VALID_NOT_EMPTY,
> 'userCode' => VALID_NOT_EMPTY
> );
>
> Please help.
>
> Louie Mirandahttp://www.axisihift.com
>
> On Jul 26, 11:49 am, Grant Cox <[EMAIL PROTECTED]> wrote:
>
> > Is your index() function the form?
>
> > If so, to re-show the form just call render(), or let the execution
> > fall out the bottom, where render() will be automatically called.
> > Don't redirect the user - this will cause a whole new page request and
> > so the existing data is lost.
>
> > If your index() is not your form (just the form processor), then you
> > will need to explicitly call render with the correct view to show.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---