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

class Login extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Login_Model');
    }

    public function index()
    {
        $userName = $this->session->userdata('user_userName');
        if (isset($userName))
            redirect(base_url('Dashboard'));
        else
            $this->load->view('Login/login');
    }

    public function check()
    {
        $user_userName = $this->input->post('userName', true);
        $user_Password = $this->input->post('Password', true);
        $remember_Me = $this->input->post('remember_Me', true);
        if (!empty($user_userName) && !empty($user_Password)) {
            $retrieve = $this->Login_Model->Login_Check($user_userName, $user_Password, $remember_Me);
            if ($retrieve == "logged") echo "logged";
            elseif ($retrieve == "no_user") echo "no_user";
            elseif ($retrieve == "ban_user") echo "ban_user";
        } else echo "empty";

    }
}
