<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Login extends CI_Controller
{


	public function index()
	{
		$data['title'] = 'arifahpulsa';
		$this->load->view('login', $data);
	}


	public function aksi_login()
	{
		$mst_petugas_email = htmlspecialchars($this->input->post('nama', true));
		$mst_petugas_password = sha1(htmlspecialchars($this->input->post('pass', true)));

		$query = $this->db->query("SELECT * from tbl_mst_petugas where mst_petugas_email='$mst_petugas_email' and mst_petugas_password='$mst_petugas_password'");
		if ($query->num_rows() > 0) {
			foreach ($query->result() as $row) {
				$sess = array(
					'mst_petugas_id' => $row->mst_petugas_id,
					'mst_petugas_kode' => $row->mst_petugas_kode,
					'mst_petugas_nama_lengkap' => $row->mst_petugas_nama_lengkap,
					'mst_petugas_email' => $row->mst_petugas_email,
					'mst_petugas_status' => $row->mst_petugas_status,
				);
				$this->session->set_userdata($sess);
			}
			redirect('dashboard');
		} else {
			$this->session->set_flashdata('error', 'Email atau password salah');
			redirect('');
		}
	}
}
