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

class Depan extends CI_Controller {

	public function __construct()
    {
        parent::__construct();   
		$this->load->model('login','l');
		$this->load->model('histori_m','data');
		
    }

	public function index()
	{
		$d['judul']="Depan";
		
		$username=$this->session->userdata('username');
		if($username!="")
		echo"<html><head><meta http-equiv='refresh' content='0;url=".base_url()."index.php/member'></head><body></body></html>";
		
		
		$this->load->view("depan");
	}

	public function cek_login()
	{
		
		$username = $this->input->post('username');
		$sandi = $this->input->post('sandi');
		
		$username=str_replace("'", "", $username);
		$sandi=str_replace("'", "", $sandi);

		
			$cek = $this->l->cek_siswa($username, $sandi);
		
		
			if($cek =="0"){
				echo "<script>alert('Maaf username atau password salah')</script>";
				echo"<html><head><meta http-equiv='refresh' content='0;url=".base_url()."'></head><body></body></html>";
				exit;
			}
			elseif($cek !="0"){
	
					$nama=balik("at_login", "nama", "username", $username);
					$hak=balik("at_login", "hak", "username", $username);
					$sess_data['username'] = $username;
					$sess_data['member_nama'] = $nama;
					$sess_data['hak'] = $hak;
					$this->session->set_userdata($sess_data);
					echo"<html><head><meta http-equiv='refresh' content='0;url=".base_url()."index.php/member'></head><body></body></html>";
			}
			
		
		
		
	}
	
	
	function logout()
	{
		$this->session->sess_destroy();
		header('location:'.base_url().'');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */