<?php include("config.inc");

$isError=false;
$usrname=$_REQUEST["username"];
$password=$_REQUEST["password"];

    
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $qry=mysqli_query($connect, "select * from users where Username='".$_REQUEST["username"]."' and Password='".$_REQUEST["password"]."' and Type='admin' and Type!='user'") or die("Error " .mysqli_error());
    $data1=mysqli_fetch_assoc($qry);
    
        
    if(mysqli_num_rows($qry)>0){
        $_SESSION['userid']=$data1['Id'];
        $_SESSION['name']=$data1['FullName'];
        $_SESSION['username']=$data1['Username'];
        $_SESSION['password']=$data1['Password'];
        $_SESSION['image']=$data1["Image"];
		$_SESSION['email']=$data1["Email"];
		
		$_SESSION['logged'] = true;
		
		header("location:index.php");
        
    }else{
        $isError=true;
		$error_msg = "Your username or password is invalid";
    } 
}



 ?>
<!DOCTYPE html>
<html lang="en">

<?php include("head-tag.php");?>
<body>

<div class="inner-wrapper login-body">
<div class="login-wrapper">
<div class="container">
<div class="loginbox shadow-sm">
<div class="login-left">
<?php echo $companylogo;?>
</div>
<div class="login-right">
<div class="login-right-wrap">
<h1><?php echo $companylogosmall;?> </h1>   
<h1>Login</h1>
<p class="account-subtitle">Access Dashboard</p>
<?php
if($isError == true){?>
	<span class="text-danger text-center"><?php echo $error_msg;?></span>
<?php }
?>
<form action="" method="POST">
<div class="form-group">
<input class="form-control" type="text" placeholder="Username" name="username" required>
</div>
<div class="form-group">
<input class="form-control" type="password" placeholder="Password" name="password" required>
</div>
<div class="form-group">
<!--<button class="btn btn-theme button-1 text-white ctm-border-radius btn-block" type="submit">Login</button>-->
<button class="btn btn-theme text-white ctm-border-radius btn-block" type="submit">Login</button>
</div>
</form>

</div>
</div>
</div>
</div>
</div>
</div>

<script src="assets/js/jquery-3.2.1.min.js"></script>

<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<script src="assets/plugins/theia-sticky-sidebar/ResizeSensor.js"></script>
<script src="assets/plugins/theia-sticky-sidebar/theia-sticky-sidebar.js"></script>

<script src="assets/js/script.js"></script>

</body>

</html>