<?php
/* 
 * Generated by CRUDigniter v3.2 
 * www.crudigniter.com
 */
 
class login extends CI_Controller{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Calisan_model');


    } 
	
	
	  function index()
    {
			$data['hata']='';
            $data['_view'] = '';
			$this->load->view('login',$data);
      
    }  
	
	   
	/*
     * giriskontrol
	 
     */
    function login()
    {

	  if(isset($_POST) && count($_POST) > 0)
        {   
          
				$kulad = $this->input->post('kulad');
				$sifre = $this->input->post('sifre');
           
            
				$result = $this->Calisan_model->loginverikontrol($kulad,$sifre);
			  if (empty($result)) {
	
					$data['hata'] = "Giriş İşlemi Başarısız";
					$data['_view'] = '';
					$this->load->view('login',$data);
					
					
				}else {

				
				$this->session->set_userdata('userid', $result->id);
				$this->session->set_userdata('userad', $result->ad);
				$this->session->set_userdata('userprofil', $result->profil);
				$this->session->set_userdata('useryetki', $result->tur);
				
				
			
				//Sayfalama
				$this->session->set_userdata('sayfaadet', 6);
				
					 redirect('anasayfa/index');
				}
			
           
        }
	
    }  
	  function cikis()
    {   
		
			
			$this->session->unset_userdata('userid');
			$this->session->unset_userdata('userad');
			$this->session->unset_userdata('useryetki');
			$this->session->unset_userdata('userprofil');
			
			
            redirect('login/index');
      
    }  
    
}
