<?php
// JavaScript Document
/**
 * @copyright	Copyright (C) Lab Imagination. All rights reserved.
 * @license  Lab Imagination, see LICENSE.php
 * Lab Imagination! is not free web application. This version may not have been modified pursuant
 * to the Lab Imagination License, and as not distributed it is not included or
 * is not derivative of works licensed under the Lab Imagination License.
 * See COPYRIGHT.php for copyright notices and details.
*/
session_start();
if(!empty($_POST["username"]) && $_POST["username"]!="")
{
 include_once("config/db_connect.php");
 $loginID=htmlspecialchars($_POST['username'],ENT_QUOTES);
 //$loginID="administrator";
 //$IP = $_SERVER['REMOTE_ADDR'];
 //secure password  
 //$pass=$_POST['password'];
 
 //$encpass=base64_encode($pass);
 
 //$IP = $_SERVER['REMOTE_ADDR'];
 
 //now validating the username and password
 $query="SELECT  id,real_name,role_id FROM  ".$prefix."users  WHERE user_id='".$loginID."'";
 //echo $query;exit;
 $result=mysqli_query($linkid,$query);

 //if username exists
 if(mysqli_num_rows($result)==1)
   {
        $row=mysqli_fetch_row($result);
		$_SESSION['userID']=$row[0]; 
		$uid=$_SESSION['userID'];
		$_SESSION['name']=ucwords($row[1]);
	    $name=$_SESSION['name'];
		
		$_SESSION['role_id']=$row[2];
	    $userroll=$_SESSION['role_id'];		
	    
		$_SESSION['emp_name']=$row[1];
	    $username=$_SESSION['emp_name'];
		//echo $userroll;
		
		 
		 //$query="INSERT INTO ".$prefix."logged_user values(null,'$uid',CURTIME(),'',CURDATE(),'$IP','$name')";		
		// $result=mysql_query($query);
		// echo "yes";
		header('location:dashboard.php');
    }
	//elseif(mysqli_num_rows($result)==0)
   ///{
   		//echo "no";
		//header('location:login-error.html');
    //}
}
?>