<?php
include "top.php";


$uid=md5(mysqli_real_escape_string($con,$_POST['uid']));
$pass=md5(mysqli_real_escape_string($con,$_POST['pass']));


$check=f(q("SELECT * FROM tbl_login WHERE l_uid='$uid' AND l_pass='$pass'"));
if($check['l_name']!=''){

   if (!empty($_POST["loggedin"])){
  
      // Username is stored as cookie for 10 years as
      // 10years * 365days * 24hrs * 60mins * 60secs
      setcookie("user_login", $uid, time() +
                          (10 * 365 * 24 * 60 * 60));

      // Password is stored as cookie for 10 years as 
      // 10years * 365days * 24hrs * 60mins * 60secs
      setcookie("user_password", $pass, time() +
                          (10 * 365 * 24 * 60 * 60));

      //echo $_COOKIE["user_login"];

  }
  else
  {
      if (isset($_COOKIE["user_login"]))
      {
          setcookie("user_login", "");
      }
      if (isset($_COOKIE["user_password"]))
      {
          setcookie("user_password", "");
      }
  }

$_SESSION['murgibhai']=$uid;
if($check['l_read']=='SUMANTA'){
    $_SESSION['lread']='admin';

}else{

    $_SESSION['lread']=$check['l_read'];
}

$_SESSION['lype']=$check['l_type'];
$_SESSION['compids']=$check['zone_id'];
// company details
$company = f(q("SELECT * FROM tbl_company WHERE c_id='$check[zone_id]'"));
$_SESSION['company']=$company;
   
   header("Location:index.php");

}else{
 header("Location:login.php");

}




?>