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 {
- /**
- * Index Page for this controller.
- *
- * Maps to the following URL
- * http://example.com/index.php/welcome
- * - or -
- * http://example.com/index.php/welcome/index
- * - or -
- * Since this controller is set as the default controller in
- * config/routes.php, it's displayed at http://example.com/
- *
- * So any other public methods not prefixed with an underscore will
- * map to /index.php/welcome/<method_name>
- * @see https://codeigniter.com/user_guide/general/urls.html
- */
- /*public function __construct()
- {
- parent::__construct();
- }*/
- public function index()
- {
- $this->load->view('login/index');
- }
- public function masuk()
- {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $cek = $this->m_login->cek($username,$password);
- if($cek->num_rows()==1)
- {
- foreach ($cek->result() as $data) {
- # code...
- $sess_data['id_username'] = $data->id_username;
- $sess_data['username'] = $data->username;
- $this->session->set_userdata($sess_data);
- }
- redirect('home');
- }
- else
- {
- $this->session->set_flashdata('pesan','Maaf username dan password tidak cocok!');
- redirect('login');
- }
- }
- function keluar()
- {
- $this->session->sess_destroy();
- redirect('login');
- }
- }
Add Comment
Please, Sign In to add comment