Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Login extends CI_Controller {
- public function _construct()
- {
- parent::_construct();
- $this->load->model('MUser');
- }
- public function index()
- {
- if ($this->session->userdata('logged') == true ) {
- redirect('rental') ;
- }else{
- $this->load->view('login');
- }
- }
- public function validasi()
- {
- $this->load->library('form_validation');
- $this->form_validation->set_rules('username', 'Username', 'required');
- $this->form_validation->set_rules('password', 'Password', 'required');
- if($this->form_validation->run() == true) {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- if($this->MUser->CheckUser($username,$password) == true) {
- $data = array('username'=>$username, 'logged'=>true);
- $this->session->set_userdata($data);
- redirect('rental');
- }else{
- $this->session->set_flashdata('pesan', 'Username atau password anda salah');
- redirect('Login');
- }
- } else {
- $this->load->view('login');
- }
- }
- public function logout()
- {
- $this->session->session_destroy();
- redirect('Login', 'referesh');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement