is this the right way ?
If this is the right way to use LoadMoel (see below code), then won't
the model be
re-instantiated each time the user types in an incorrect password?

//controller
function login()
   {
                $this->pageTitle = "Login";
                $this->set('pageImage', 'login-welcome.gif');
                $arr_validation_errors = array();

                $this->loadModel( 'Member' );
                $this->Member = &new Member();

                //render view if user is logged in
                if($this->Authentication->_isLoggedin())
                {
                        $this->redirect('/members/');
                        exit;
                }

                if (empty($this->params['data']))
                {
                        $this->render();
                }
                else
                {
                        //has password
                        $this->sanitize->cleanArray($this->params['data']);
                        $password = 
md5($this->params['data']['Member']['password']);

                        if ($this->Member->validates($this->params['data']))
                        {
                                $results = $this->Member->find("email_address =
'".$this->params['data']['Member']['email_address']."' AND password =
'". $password ."'",'Member.id,Member.fname');

                                if ($results['Member']['id'])
                                {
                                        //sets up the session vars
                                        
$this->Authentication->set($results['Member']);
                                        $this->Member->id = 
$results['Member']['id'];
                                        $_POST = array();//make sure the post 
is cleared out
                                        $this->redirect('/members/');
                                }
                                else
                                {
                                        array_push($arr_validation_errors, 
"Please enter a correct email
address and/or password");
                                        
$this->params['data']['Member']['password'] = '';
                                        $this->set('data', 
$this->params['data']);
                                        $this->set('arr_validation_errors', 
$arr_validation_errors);
                                        $this->validateErrors($this->Member);
                                }
                        }
                        else
                        {
                                $this->set('data', $this->params['data']);
                                $this->validateErrors($this->Member);
                        }
                }
        } //end function


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to