<?php

class M_login extends CI_Model {

    public function cekLogin($data)
	{
        $username = $data['email'];
		$cekLogin = $this->db->get_where('data_alumni',$data)->num_rows();
        if($cekLogin > 0){
            $sessionData = array(
                'username' => $username,
                'login' => TRUE,
            );
            $this->session->set_userdata($sessionData);
            redirect('alumni');
        }else{
           echo '<script>alert("Username atau Password salah.");
            window.location.assign("index")</script>';      
        }
	}

    public function cekLoginAdmin($data)
	{
        $username = $data['username'];
		$cekLogin = $this->db->get_where('data_admin',$data)->num_rows();
        if($cekLogin > 0){
            $sessionData = array(
                'username' => $username,
                'login' => TRUE,
            );
            $this->session->set_userdata($sessionData);
            redirect('admin/admin_view');
        }else{
            echo '<script>alert("Username atau Password salah.");
            window.location.assign("admin_login")</script>';      
            //redirect('admin/admin_login');
        }
	}

    public function detailAdmin($username)
	{
		$query = $this->db->get_where('data_admin', array('username' => $username))->row();
		return $query;
	}

}

?>