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

class Adminstrator_Login extends CI_Controller {
    
	public function Login_Admin()
	{
        $this->load->library('form_validation');
       // $this->form_validation->set_rules('cid', 'text', 'required');
        $this->form_validation->set_rules('pwd', 'text', 'required');
        

        if($this->form_validation->run())
        {
            $cid=$this->input->post('cid');
            $pwd=$this->input->post('pwd');

            //echo "CID:".$cid;

            $cid=urldecode($cid);
            $cid=trim($cid);
            $this->load->model('Can_login');

            if($this->Can_login->can_admin_login($cid,$pwd))
            {
                redirect(base_url()."index.php/Login/show_data/".$cid);
            }
            else
            {
                $this->session->set_flashdata('error','Invalid username or password');
                redirect(base_url().'index.php/Login');
            }
            
        }
        else
        {
            echo "not admin";
        }
    }
    
}


