Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') or exit ('Akses langsung tidak diperbolehkan');
- /**
- *
- */
- class c_login extends CI_Controller{
- public function __construct(){
- parent::__construct();
- if ($this->session->userdata('username')) {
- redirect(base_url('admin'));
- }
- $this->load->model(array('m_login'));
- }
- public function index(){
- $this->load->view('login');
- }
- public function proses(){
- $this->form_validation->set_rules('username','username','required|trim|xss_clean');
- $this->form_validation->set_rules('password','password','required|trim|xss_clean');
- if ($this->form_validation->run() == FALSE){
- $this->load->view('login');
- }
- else {
- $user = $this->input->post('username');
- $pass = $this->input->post('password');
- $u = $user;
- $p = sha1($pass);
- $cek = $this->m_login->cek($u,$p);
- if ($cek->num_rows() > 0){
- foreach ($cek->result() as $row){
- $sess_data['username'] = $row->username;
- $sess_data['password'] = $row->passsword;
- $sess_data['nama'] = $row->nama;
- $this->session->set_userdata($sess_data);
- }
- $this->session->set_flashdata('succes','login berhasil');
- redirect('c_admin/admin');
- }
- else{
- $this->session->set_flashdata('result_login', 'Username atau Password yang anda masukkan salah.');
- redirect('c_login/login');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement