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 {
- public function __construct(){
- parent::__construct();
- $this->load->model('m_login');
- }
- public function index()
- {
- $this->load->view('v_login');
- }
- public function aksi_login(){
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $where = array(
- 'username' => $username,
- 'password' => md5($password)
- );
- $cek = $this->m_login->cek_login("admin", $where)->num_rows();
- if($cek > 0){
- $data_session = array(
- 'nama' => $username,
- 'status' => 'login'
- );
- $this->session->set_userdata($data_session);
- redirect(base_url('admin'));
- }else{
- echo "<script>alert('username atau password salah')</script>";
- $this->index();
- }
- }
- public function logout(){
- $this->session->sess_destroy();
- redirect(base_url('login'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement