Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Login_Controller extends CI_Controller {
- public function index()
- {
- $this->Login_Model->login_check();
- $username = $this->input->post('username');
- $this->form_validation->set_rules('username', 'Kode Pengguna', 'callback_username_check');
- $this->form_validation->set_rules('password', 'Kode Sandi', 'callback_password_check');
- if ($this->form_validation->run() == FALSE) {
- $this->load->view('login');
- }
- else {
- $newdata = $this->Login_Model->get_info($username);
- $this->session->set_userdata($newdata);
- redirect('beranda');
- }
- }
- public function username_check()
- {
- $username = $this->input->post('username');
- $username_check = $this->Login_Model->username_check($username);
- if ($username_check == 0) {
- $this->form_validation->set_message('username_check', '<span class="glyphicon glyphicon-info-sign text-warning"></span> {field} belum terdaftar');
- return FALSE;
- }
- else {
- $active_check = $this->Login_Model->active_check($username);
- if ($active_check == FALSE) {
- $this->form_validation->set_message('username_check', '<span class="glyphicon glyphicon-remove-sign text-danger"></span> {field} tidak mempunyai akses');
- return FALSE;
- }
- else {
- return TRUE;
- }
- }
- }
- public function password_check()
- {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- if ($this->username_check() == FALSE) {
- $this->form_validation->set_message('password_check', '');
- return FALSE;
- }
- else {
- $store = $this->Login_Model->password_check($username);
- if (password_verify($password, $store)) {
- return TRUE;
- }
- else {
- $this->form_validation->set_message('password_check', '<span class="glyphicon glyphicon-remove-sign text-danger"></span> {field} tidak sesuai.');
- return FALSE;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement