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.

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');

add this line before redirect code
$this->load->helper('url');

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.