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 extends CI_Controller
- {
- function __construct()
- {
- parent::__construct();
- $this->load->model('admin'); //load model admin
- }
- public function index()
- {
- //membuat password untuk admin yang te;ah di encrypsi
- // echo password_hash('admin', PASSWORD_DEFAULT, ['cost' => 10]);
- //proses autentikasi
- if ($this->input->post('submit') == 'Submit' )
- {
- //variabelvariabel untuk menerima value yang dikirim form inputnya
- $user = $this->input->post('username', TRUE);
- $pass = $this->input->post('password', TRUE);
- //variabel untuk pengecekan
- $cek = $this->admin->get_where('t_admin', array('username' => $user));
- //jika proses verivikasi pada username sudah berjalan maka lakukan verivikasi pada password
- if ($cek->num_rows() > 0)
- {
- $data = $cek->row();
- if (password_verify($pass, $data->password))
- {
- //session
- $datauser = array
- (
- 'user' => $data->fullname,
- 'level' => $data->level,
- 'login' => TRUE
- );
- $this->session->set_userdata($datauser);
- redirect ('index.php/admin');
- }
- else
- {
- echo '<p style="color:white">Password Salah</p>';
- }
- }
- else
- {
- echo '<p style="color:white">Gagal</p>';
- }
- }
- $this->load->view('admin/login_form');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement