load->library('session'); $this->load->model('register_model','reg'); } public function index($i = null) { $data['msg'] = ''; if($i == 1) $data['msg'] = 'Username atau Password Salah'; if($i == 2) $data['msg'] = 'NIM Sudah Terdaftar pada sistem MKWU.'; $this->load->view('_templates/auth/_header.php'); $this->load->view('register/log',$data); $this->load->view('_templates/auth/_footer.php'); } public function regM($i = null) { if($_SESSION['status'] == "reg_login"){ $data['msg'] = ''; if($i == 1) $data['msg'] = 'Email Sudah Terdaftar.'; $data['kelas'] = $this->reg->getKelasMKWU(); $this->load->view('_templates/auth/_header.php'); $this->load->view('register/reg',$data); $this->load->view('_templates/auth/_footer.php'); }else{ redirect(base_url()); } } public function regis(){ if($_SESSION['status'] == "reg_login"){ $email = $this->input->get_post('email',true); if ($this->ion_auth->email_check($email)){ redirect('register/regm/1'); }else{ $nama = $this->input->get_post('nama',true); $username = $this->input->get_post('nim',true); //Proses input data mahasiswa ke tabel mahasiswa $data_mhs = array( 'nama' => $nama, 'nim' => $username, 'email' => $email, 'jenis_kelamin' => $this->input->get_post('jnskelamin',true), 'kelas_id' => $this->input->get_post('kelas',true), ); $this->reg->insert('mkwu_mahasiswa', $data_mhs); //Proses create data login $namax = explode(' ', $nama); $first_name = $namax[0]; $last_name = end($namax); $additional_data = [ 'first_name' => $first_name, 'last_name' => $last_name ]; $group = array('3'); // Sets user to dosen. $this->ion_auth->register($username, $username, $email, $additional_data, $group); // redirect('auth'); $this->session->sess_destroy(); redirect(base_url()); } }else{ redirect(base_url()); } } public function login() { // Proses login $uname = $this->input->get_post('username',TRUE); $pw = base64_encode($this->input->get_post('password',TRUE)); // proses pengecekan apakah data sudah terdaftar pada sistem MKWU $where_mkwu = array( 'nim' => $this->input->get_post('username',true) ); $cek_mhs = $this->reg->cek_mhs('mkwu_mahasiswa',$where_mkwu); if($cek_mhs > 0) { // Kondisi sudah terdaftar redirect('register/index/2'); }else{ //kondisi belum terdaftar $where = array( 'userid' => $uname, 'password' => $pw ); $cek = $this->reg->cek_login('pengguna',$where); $data = $this->reg->data_login('pengguna',$where); if($cek > 0){ $data_session = array( 'nim' => $data['userid'], 'nama' => $data['nmlengkap'], 'status' => 'reg_login', 'status_login' => 'login' ); $this->session->set_userdata($data_session); redirect(base_url().'register/regm'); }else{ redirect('register/index/1'); } } } } ?>