<?php
    session_start();
    error_reporting(0);
    include('includes/connection.php');

if(isset($_POST['login']))
    {

$email = trim($_POST['emailid']);
$password = trim($_POST['pass_word']);

$sql ="SELECT email_id, password, employee_id, status FROM employee WHERE email_id=:emailid and password=:pass_word";
$query= $dbh -> prepare($sql);

$query-> bindParam(':emailid', $email, PDO::PARAM_STR);
$query-> bindParam(':pass_word', $password, PDO::PARAM_STR);

$query-> execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);

if($query->rowCount() > 0)
    {
    foreach ($results as $result) 
    {
    $_SESSION['stdid']=$result->employee_id;
        if($result->status==1)
            {
                $_SESSION['login']=$_POST['emailid'];
                echo "<script> document.location ='dashboard.php'; </script>";
            } 
        else 
            {
                echo "<script>alert('Your Account Has been blocked .Please contact admin');</script>";
            }
    }
    } 
        else{
            echo "<script>alert('Invalid Details');</script>";
            }
    }

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        
        <title>Online inventory Management System </title>
    <!-- BOOTSTRAP CORE STYLE  -->
        <link href="assets/css/bootstrap.css" rel="stylesheet" />
        <!-- FONT AWESOME STYLE  -->
        <link href="assets/css/font-awesome.css" rel="stylesheet" />
        <!-- CUSTOM STYLE  -->
        <link href="assets/css/style2.css" rel="stylesheet" />
    </head>

    <body>
        <!------MENU SECTION START-->
        <?php include('includes/header.php');?>
    <!-- MENU SECTION END-->
        <div class="row pad-botm">
            <div class="col-md-12">
            <h4 class="header-line">EMPLOYEE LOGIN FORM</h4>
             </div>
        </div>
        <a name="ulogin"></a>            
            <!--LOGIN PANEL START-->           
            <div class="row">
                <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" >
                     <div class="panel panel-info">
                        <div class="panel-heading">
                        LOGIN FORM
                        </div>
                        <div class="panel-body">
                            
            <form role="form" method="post">
                <div class="form-group">
                <label>Enter Email id</label>
                <input class="form-control" type="text" name="emailid" required autocomplete="off" />
                </div>
                <div class="form-group">
                <label>Password</label>
                <input class="form-control" type="password" name="pass_word" required autocomplete="off"  />
                <p class="helpblock"><a href="user-forgot-password.php">Forgot Password</a></p>
                </div>

            <button type="submit" name="login" class="btn btn-info">User Login </button> | <a href="signup.php">Not Register Yet</a>                                                     
            </form>
                         </div>
                    </div>
                </div>
            </div>  
    <!---LOGIN PABNEL END-->         
        <!-- CONTENT-WRAPPER SECTION END -->
    <?php include('includes/footer.php');?> 
    </body>
</html>