<?php

session_start();
include('includes/connection.php');
if (isset($_POST['login'])) 
{
  $useridno=0;
  $username = $_POST['username'];
  $userpassword = $_POST['userpassword'];  
  $stmt = $mysqli->prepare("SELECT user_name, user_password, user_idno FROM user_creation WHERE user_name=? AND user_password=?");
  $stmt->bind_param('ss', $username, $userpassword); 
  $stmt->execute(); 
  $stmt->bind_result($username, $userpassword, $useridno); 
  $rs = $stmt->fetch();
  $_SESSION['loginid'] = $useridno; 
  $_SESSION['loginname'] = $username;
 
  if ($rs) 
  { 
     header("location:dashboard.php");
  } 
  else 
  {
     unset($_SESSION['loginid']);
     unset($_SESSION['loginname']);
     session_destroy();
     $err = "Access Denied Please Check Your Credentials";
  }
}

?>


  <!DOCTYPE html>
  <html>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <?php include("includes/head.php"); ?>

  <body class="hold-transition login-page">
    <div class="login-box">
      <div class="login-logo">
        <p>PROGRAMERS INTERNATIONAL</p>
      </div>

      
      <div class="card">
        <div class="card-body login-card-body">
          <p class="login-box-msg">Log In To Start Adminstrator Session</p>

          <form method="post">
            <div class="input-group mb-3">
              <input type="text" name="username" class="form-control" placeholder="UserName">
              <div class="input-group-append">
                <div class="input-group-text">
                  <span class="fas fa-envelope"></span>
                </div>
              </div>
            </div>
            <div class="input-group mb-3">
              <input type="password" name="userpassword" class="form-control" placeholder="PassWord">
              <div class="input-group-append">
                <div class="input-group-text">
                  <span class="fas fa-lock"></span>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-4">
                <div class="icheck-primary">
                </div>
              </div>

              <div class="col-8">
                <button type="submit" name="login" class="btn btn-danger btn-block">Log In As Admin</button>
              </div>

            </div>
          </form>

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

    <script src="plugins/jquery/jquery.min.js"></script>
    <script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="dist/js/adminlte.min.js"></script>

  </body>

  </html>
