0
votes

I have completed a website in codeigniter. The login page is working in localhost but when I am uploading the same onto the server, the login page is not working. It is showing a blank white page.

$this->load->model("studentsmodel");
$result = $this->studentsmodel->loginCheck($post_data); 
if (!$result) {


$this->notifications->notify('Wrong username or password; Login Failed', 'error');
redirect('site/login', 'refresh');
}
else {
            $this->session->set_userdata('student_id', $result['id']);
            $this->session->set_userdata('stud_cin', $result['stud_cin']);
            $this->session->set_userdata('stud_path', $result['stud_path']);

            redirect('student/id/'.$this->session->userdata('student_id'), 'refresh');

    }

This is the code for login page in codeigniter. If there is no value in $result, the notification "wrong username/password" is not working. Also if there is data inside $result , it is not going to else part. In both the cases it is showing a white blank page. Can anyone suggest a solution for this ? I am using CI 2.1. This all is working properly in the localhost but not in the server. Any problm with refresh being used with redirect().

output of $result is

Array
(
[id] => 2
[stud_cin] => 11AK11
[stud_path] => photo/no-photo.JPG
)
2
Make sure the error is not from database. Set $db['default']['db_debug'] = TRUE; in config->database.php. - Shihas
true value is already set for this parameter. - Ancy
Data from database in all other pages is working.only the login page is not working on the server. But login page is working in the localhost. - Ancy
database connectivity is not the issue..some redirection problm.. - Ancy
Try this in else condition redirect('student/id/'.$result['id']); - Shihas

2 Answers

0
votes

Try the below code:

$this->load->model("studentsmodel");
$result = $this->studentsmodel->loginCheck($post_data);  

if($result) {
    $id = $this->session->set_userdata('student_id', $result['id']);
    $stud_cin = $this->session->set_userdata('stud_cin', $result['stud_cin']);
    $stud_path = $this->session->set_userdata('stud_path', $result['stud_path']);

    redirect('student/id/'.$id);
}else{
    // $this->notifications->notify('Wrong username or password; Login Failed', 'error');
    redirect('site/login');
}
0
votes

Try this

$this->load->model("studentsmodel");
$result = $this->studentsmodel->loginCheck($post_data); 
if($result) {
    if(isset($result['id']) && $result['id'] !== ''){
      $this->session->set_userdata(array(
        'student_id'=>$result['id'],
        'stud_cin'=>$result['stud_cin'],
        'stud_path'=>$result['stud_path']
      ));
      redirect('student/id/'.$result['id'], 'refresh');
    }
    else{
        redirect('site/login', 'refresh');
    }
}
else {
  redirect('site/login', 'refresh');
}