<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Login extends CI_Controller
{
     public function __construct()
    {

        parent::__construct();
        $this->load->model('login_model', 'login');
    }

    public function index()
    {
        $data['title']    = 'Login';
        $this->load->view('login.php' , $data);
    }
    public function check_login () 
    {
        
        $email=$this->input->post('email');
        $password=md5($this->input->post('password'));
        
        $result=$this->login->check_login_info($email,$password);
        
            if(!empty($result)) {
                $data['admin_id']=$result->admin_id;
                $data['email']=$result->email;
				$data['name']=$result->name;
                $this->session->set_userdata($data);
                redirect('admin/index');
                
            } else {
                $this->session->set_flashdata('msg', '<div style="color:red;" class="text-center">Email or Password Wrong ! Try Again</div>');
                 redirect('login');
                }
    }
   
}
