creating a basic log in page – it was working but then we changed our database and our redirect is no longer working.
when we go to log in the site comes back saying that the username/password is incorrect, after checking the sql code that the site is checking against the database – it is sending the correct information but not allowing us to log in.
we want the user when they log into the site to get redirected to the eboxs(controller) home(view).
here is the code in the controller for logging in
public function login(){
$this->set('title_for_layout', 'Individual Registration');
$this->set('stylesheet_used', 'style');
$this->set('image_used', 'eBOXLogo.jpg');
if ($this->request->is('post')){
if ($this->Auth->login()){
$username = $this->request->data['User']['username'];
if (0 === $this->User->find('count',array('conditions'=>array('activated'=>true,'username'=> $username)))){
$this->Session->setFlash('Sorry, your account is not validated yet.');
$this->redirect($this->referer());
}
else{
$this->Auth->user('id');
$this->redirect( array('controller' => 'Eboxs','action' => 'home'));
}
}
else{
$this->Session->setFlash('Username or password is incorrect');
}
}else{
$this->Session->setFlash('Welcome, please login');
}
}
here is the code for the view
<?php
echo $this->Form->create('User', array('action' => 'login'));
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('Login');
?>
Enable the debug mode to ‘2’ in core.php file when you are changing database or you can remove the model cache. You can later on change the debug mode to 0 in the production site. Also check that you have a valid username and password in the users table of the new database.Also check the structure of the password field.It should be varchar 255.
Also Modify the above logic to –
In view file instead of using
Try using –