I have created a login page using CodeIgniter 1.7. its code is shown below:

<?php
class login extends Controller {
    function login()
    {
        parent::Controller();   
    }   
    function index()
    {
        $this->load->view('loginview');
    }
function verify()
{
  if ($this->input->post('username')){
    $uname = $this->input->post('username');
    $upass = $this->input->post('password');
    $result=$this->dblogin->verifyUser($uname,$upass);
   if($result){
     redirect('dashboards','refresh');
    }}
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

there is an external model for selecting users from database. if you enter correct details, it displays a blank page but if you enter invalid credentials, it will display the error message. can somebody put it better to redirect to dashboards controller.

Edited 3 Years Ago by pyTony: fixed formatting

Point the redirect to a controller not to a view. So change 'dashboard' to '/dashboard' or '/your_controller/dashboard'. You can also remove 'refresh' it will speed up the redirect. Add an ELSE statement:

if($result){
    redirect('/dashboards');
}
else
{
    echo 'error';
}

And remember to load the url helper before the redirect or in your autoload.php config file: $this->load->helper('url');

Edited 5 Years Ago by cereal: n/a

This article has been dead for over six months. Start a new discussion instead.