Q:

CodeIgniter: Login in the main page

I'm trying to have my login controller in my main page, but when I try to login it goes to a page with just the view/login code. 
Here is my controller:
public function home(){
    $this->load->model("get_products");
    $data['results'] = $this->get_products->getData();

    $this->load->view("site_header");
    $this->load->view("site_nav");
    $this->load->view("content_home", $data);
    $this->load->view("content_left");
    $this->load->view("content_right");

    $this->login();
    $this->login_validation();

    $this->load->view("site_footer");
}

public function login(){
    $this->load->view('login');
}
public function login_validation(){
    $this->load->library('form_validation');
    $this->form_validation->set_rules('email', 'Email', 'required|trim');
    $this->form_validation->set_rules('password', 'Password', 'required|md5');

    if($this->form_validation->run()){
        $this->load->view('logged');
    } 

}

How can I login in the home page, without loading a new page? 

A:

No need of 2 functions, use one function like this, 
public function login(){

    $this->load->library('form_validation');
    $this->form_validation->set_rules('email', 'Email', 'required|trim');
    $this->form_validation->set_rules('password', 'Password', 'required|md5');

    if($this->form_validation->run() == FALSE){
        $this->load->view('login'); 
    } else {
        // here you can redirect to main controller instead of loading the view, since ligin part is related here
        $this->load->view('logged');
    } 

}

And you are calling 2 functions in home()
$this->login();
$this->login_validation();

Both will not get called as you are loading a view in first one.