<?php include'header.php';?>
<?php
if(isset($_SESSION['id'])){ ?>
<script type = "text/javascript">window.location = "home.php";</script>
<?php } ?>

<?php
    if(isset($_POST['login'])){
$number=$_POST['number'];
$password=$_POST['password'];
//Function Calling
$ret=$obj->login($number,$password);
$num=mysqli_fetch_array($ret);
if($num>0) {
	$_SESSION['user']['login']=TRUE;
	$_SESSION['id']=$num['id'];
	header('location: home.php');
}else { echo '<div class="alert alert-info -2">incorrect usename or password</div>'; }
}
?>


<div class="card login-card">
    
    <div class="card-header">
        Login Panel
    </div>

    <div class="card-body p-4">
 
        <form action="" method="POST">

            <div class="mb-3">
                <label>Number</label>
                <input type="" name="number" class="form-control" placeholder="Enter Number" required>
            </div>

            <div class="mb-3">
                <label>Password</label>
                <input type="password" name="password" class="form-control" placeholder="Enter Password" required>
            </div>

            <div class="d-grid">
                <button type="submit" name="login" class="btn btn-login">
                    Login
                </button>
            </div>

        </form>
        <hr>
        <center><a href="registration.php">Create New Account</a></center>

    </div>

</div>


<?php include'footer.php';?>