Hi guys,
I’m new to CI, and right now I’m working on login system with registration. I need to load single view at a time, i.e. when the user logged in profile view should only be
viewed but I found that profile view appended to login view. Here the code for better explanation.
function logger(){
$this->load->view('login_view.php');
if ((!empty($_POST['userTextField'])) && (!empty($_POST['passwordField'])))
{ //$_POST array not empty
$this->load->model('login_model');
$this->login_model->getData($_POST);
$result = $this->login_model->checkLogin();
if($result){
echo '[removed]alert("You sucessfully logged in");[removed]';
//create a new session.
$user = array('username' => $_POST['userTextField'], 'logged_in' =>'TRUE');
$this->session->set_userdata($user);
//redirect to userContent.php view page.
$this->load->view('userContent2.php');
}else
echo '[removed]alert("You are not registered. Please register");[removed]';
}else{
//$_POST array empty
echo '[removed]alert("Missing data.");[removed]';
}
}