[eluser]WanWizard[/eluser]
You shouldn't load views in your model. Model methods are strictly behind the scenes blocks of code.
Instead, do
Code:
function sahDaftarmasuk($alnamapengguna, $alkatalaluan)
{
$this->db->where('namapengguna',$alnamapengguna);
$this->db->where('katalaluan',$alkatalaluan);
$this->db->where('keaktifan','1');
$dapatmaklumat = $this->db->get('spkppi_pengguna');
if($dapatmaklumat->num_rows() > 0)
{
$maklumatpengguna = array();
$maklumatpengguna = $dapatmaklumat->row_array();
return $maklumatpengguna;
}
else
{
return FALSE;
}
}
Code:
function daftarmasuk()
{
$this->form_validation->set_rules('namapengguna', 'Nama Pengguna', 'required|trim|max_length[100]|xss_clean');
$this->form_validation->set_rules('katalaluan', 'Kata Laluan', 'required|trim|min_length[6]|max_length[20]|xss_clean');
if ($this->form_validation->run() === FALSE)
{
$data['pagetitle'] = "maklumat sekolah";
$this->load->vars($data);
$this->load->view('vsyslogin');
}
else
{
$this->load->Model('Msyslogin');
$maklumatpengguna = array();
$alnamapengguna = $this->input->post('namapengguna');
$alkatalaluan = do_hash(do_hash($this->input->post('katalaluan')),'md5');
$maklumatpengguna = $this->Msyslogin->sahDaftarmasuk($alnamapengguna, $alkatalaluan);
if($maklumatpengguna === FALSE)
{
redirect('vsyslogin');
}
elseif($maklumatpengguna['kelayakkan'] == 0)
{
$data['kelayakkan'] = $maklumatpengguna['kelayakkan'];
$this->load->view('admin/avdashboard', $data);
}
else if ($maklumatpengguna['kelayakkan'] == 1)
{
$this->load->view('pkelas/pjdashboard');
}
else if ($maklumatpengguna['kelayakkan'] == 2)
{
$this->load->view('psyarikat/psdashboard');
}
else
{
redirect('vsyslogin');
}
}
}
So have your model methods return the values they are supposed to retrieve, or FALSE is there is an error. Check the return value in the controller, and base your descisions on that value. Your controller should contain the application flow logic, not the model.