How to login with an element in CakePHP? -
currently have functional login procedure. users go specific login view, type username , password, access , redirected specific dashboard.
in users controller:
public function login() { if ($this->request->is('post')) { if ($this->auth->login()) { return $this->redirect(); } $this->session->setflash('incorrect user or password.'); } }
the login view:
<h1>access username:</h1> <?php echo $this->form->create('user', array('action' => 'login')); echo $this->form->input('username', array('label' => 'user:')); echo $this->form->input('password', array('label' => 'password:')); echo $this->form->end('login'); ?>
the issue came when asked add login fields directly in main menu. tried adding them element in header. didn't work.
the element i'm adding in header:
<div> <?php echo $this->form->create('user', array('action' => 'login')); echo $this->form->input('username', array('placeholder' => 'user', 'label' => false)); echo $this->form->input('password', array('placeholder' => 'password', 'label' => false)); echo $this->form->submit('ingresar', array('div' => true)); echo $this->form->end(); ?> </div>
i enter username , password , click "login" button. throws me "incorrect user or password." error message , redirects me view login action (without login in user).
in there, 1 can login without further issue, point reduce 1 needed clicks action.
what missing? should change/add/move?
in second html form, model user
not typed should be
change
echo $this->form->create('user', array('action' => 'login'));
to
echo $this->form->create('user', array('action' => 'login'));
note u
changed u
model name
Comments
Post a Comment