I am trying to direct the user to my main page when the user is authorized. I am doing the user check in my login_check controller and add $this->load->view('main');
The page can be load but the site address in the main page still show
http://myprojectname/login_check
but I want it to show
http://myprojectname/main.
Do i have to create a new 'main' controller and load the view? It sounds redundant to me. Here is my code.
part of my login_check.php
private function _user_check()
{
$this->load->model('user_query'); //load my model
$result=$this->user_query->query($this->input->post('username'),$this->input->post('password'))
if($result) //the user is in DB
{
$data['view']='main';
$this->load->view('include/template', $data);
//the address bar shows http://myproject/login_check in main page
}else{ //the user is not in DB
$data['view']='login';
$this->load->view('include/template', $data);
}
}
First of all, you are doing a very poor job of checking if the user is authenticated (just passing username/pass to model isn't best, should process / check it before sending to model).
You can make redirects easily by including the helper 'URL' and simply use:
redirect('/controller/method');
or in a real world example:
redirect('/main');
Reference Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With