[eluser]imanhunter[/eluser]
Hi,
I'm struggling to learn how to transfer data between model & controller. Yes, I'm new to both PHP & CI so you can call me NoOb. Have learn through tutorial (vids/article) but still can't get the idea.
Below is my code
Model
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
{
$this->load->view('vsyslogin');;
}
}
here is the controller
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');
$this->Msyslogin->sahDaftarmasuk($alnamapengguna, $alkatalaluan);
if($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');
}
}
}
The idea here is if the user log into the app, then it will get the user data (namapengguna & katalaluan) from db which after that it will also get the user rank. different rank will redirect user to different dashboard.
I'm trying to get the row into an array which will return to controller then will be extracted in it.