here i am trying to log in with username "admin" and password "admin" with form validation and putting those value in session but while checking in database it is not returning any value???? my controller which verifies username and password is
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('loginModel');
$this->load->helper('string');
$this->load->library("form_validation");
}
//login
public function index()
{
$this->load->view('login');
}
Public Function authentication()
{
$username=$this->input->post('username');
$password=$this->input->post('password');
$this->form_validation->set_rules("username","Username","required");
$this->form_validation->set_rules("password","Password","required");
if($this->form_validation->run() == FALSE)
{
echo "Error";
$this->session->set_flashdata('error','Invalid User Name or PASSWORD!');
redirect(site_url().'login');
} else {
$login_data = array(
"username"=>$username,
"password"=>$password
);
$authentication_response = $this->loginModel->user_authentication($login_data);
if($authentication_response)
{
$username = $authentication_response['UserName'];
$UserTypeId = $authentication_response['UserTypeId'];
//put the user info on session
$this->session->set_userdata("username", $username);
$this->session->set_userdata("UserTypeId", $UserTypeId);
if($UserTypeId == "1")
{
redirect("dashboard");
}
if($UserTypeId == "2")
{
redirect("dashboard");
}
if($UserTypeId == "3")
{
redirect("userPanel");
}
} else {
$this->session->set_flashdata("error", "Invalid User!!! Please check your user name or password correctly");
redirect("login");
}
}
}
function logout(){
$this->session->sess_destroy();
redirect(site_url().'login');
}
}//end of class
?>
i am using sql server 2008 UserName = admin Password =admin USERTYPEID=1