Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Auth extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- $this->load->model('Auth_model');
- $this->load->library('form_validation');
- }
- public function index()
- {
- $this->load->view('auth_view');
- }
- public function aksi_login(){
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $where = array(
- 'username' => $username,
- 'password' => md5($password)
- );
- $cek = $this->Auth_model->cek_login("users",$where)->num_rows();
- if($cek > 0){
- $data_session = array(
- 'nama' => $username,
- 'status' => "login"
- );
- $this->session->set_userdata($data_session);
- redirect(base_url("home"));
- }else{
- echo "Username dan password salah !";
- }
- }
- function logout(){
- $this->session->sess_destroy();
- redirect(base_url('auth'));
- }
- }
Add Comment
Please, Sign In to add comment