session->userdata('status') === "admin_login"){ redirect('admin'); }elseif ($this->session->userdata('status') === "staff_login") { redirect('staff'); }elseif ($this->session->userdata('status') === "mahasiswa_login") { redirect('mahasiswa'); }elseif ($this->session->userdata('status') === "dosen_login") { redirect('dosen'); } $this->load->model('register_model','reg'); } // halaman login registrasi (akun siak) public function index($i = null) { $this->load->view('register/v_log_regis'); } // proses login registrasi (akun siak) 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 MBKM $where_mbkm = array( 'nim' => $this->input->get_post('username',true) ); $cek_mhs = $this->reg->cek_mhs('mahasiswa_mbkm_dalam',$where_mbkm); if($cek_mhs > 0) { // Kondisi sudah terdaftar $this->session->set_flashdata('flash_error', 'NIM sudah terdaftar dalam sistem MBKM.'); redirect('register'); }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); $this->session->set_flashdata('flash_success', 'Silahkan isi data registrasi.'); redirect(base_url().'register/regm'); }else{ $this->session->set_flashdata('flash_error', 'Username atau Password salah.'); redirect('register'); } } } // Halaman registrasi Mahasiswa inbound public function regM($i = null) { if($_SESSION['status'] == "reg_login"){ $this->load->view('register/v_regis'); }else{ redirect(base_url()); } } // Fungsi Registrasi pada halaman registrasi public function regis(){ if($_SESSION['status'] == "reg_login"){ // Proses input data mahasiswa ke tabel mahasiswa $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $data_mhs = array( 'nim' => $this->input->get_post('nim',true), 'nmmhs' => $this->input->get_post('nama',true), 'asal_prodi' => $this->input->get_post('prodi',true), 'created_at' => $time ); $this->reg->insert('mahasiswa_mbkm_dalam', $data_mhs); // Proses input data login mahasiswa $data_user = array( 'username' => $this->input->get_post('nim',true), 'password' => MD5($this->input->get_post('nim',true)), 'status' => 'mahasiswa', 'sub_lvl' => '01-INTERNAL', 'created_at' => $time ); $this->reg->insert('user', $data_user); $this->session->sess_destroy(); redirect(base_url()); }else{ redirect(base_url()); } } // Fungsi kembali ke login di halaman regis public function back_to_login() { $this->session->sess_destroy(); redirect('Landing'); } } ?>