<?php include('header.php');


if (isset($_POST['login'])) {
	$conn = new khodexclass($mysqli);
	
	if ($conn->login2($_POST['details'],$_POST['password'])) {$erro="good";  
				header('location: ./');				
				exit(0);
			
    } else {
      $erro="fatal";
    }
			

}


if(isset($_SESSION['admin']['role'])){
	//header('location: ./'); exit(0);
}

?>
    <div class="page-wrapper">
      <div class="container-fluid p-0">
        <!-- login page start-->
        <div class="authentication-main">
          <div class="row">
            <div class="col-md-12">
              <div class="auth-innerright">
                <div class="authentication-box">
                  <div class="text-center"><b><h3>ADMIN PANEL</h3></b></div>
                  <div class="card mt-4">
                    <div class="card-body">
					
					
					<?php
if ($erro == "fatal") { 	
    ?><div class="alert alert-danger left-icon-big alert-alt solid alert-dismissible fade show">
                                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="btn-close"><span><i class="mdi mdi-btn-close"></i></span>
                                            </button>
                                            <div class="media">
                                                <div class="alert-left-icon-big">
                                                    <span><i class="mdi mdi-alert"></i></span>
                                                </div>
                                                <div class="media-body">
                                                    <h5 class="mt-1 mb-1 text-light">Login failed!</h5>
                                                   <ol class="mb-0"> <?php echo"". $re ."".$re2 ."".$re3 ."".$pn_err; ?></ol>
                                                </div>
                                            </div>
                                        </div>
    <?php
}?>


                      <div class="text-center">
                        <h4>LOGIN</h4>
                        <h6>Enter your Username and Password </h6>
                      </div>
                      <form class="theme-form" method="POST" action="">
                        <div class="mb-3">
                          <label class="col-form-label pt-0">Your Username or Email</label>
                          <input class="form-control" value="<?php
if(isset($_POST['login'])){
	echo $_POST['details'];
} 	
    ?>" name="details" placeholder="Username or Email" type="text" required="">
                        </div>
                        <div class="mb-3">
                          <label class="col-form-label">Your Password</label>
                          <input class="form-control" name="password" placeholder="Password here" type="password" required="">
                        </div>
                        <div class="form-row mt-3">
                          <button class="btn btn-primary btn-block w-100" name="login" type="submit">Login</button>
                        </div>
                       
                      </form>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- login page end-->
      </div>
    </div>
    <!-- latest jquery-->
    <script src="assets/js/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap js-->
    <script src="assets/js/bootstrap/bootstrap.bundle.min.js"></script>
    <!-- feather icon js-->
    <script src="assets/js/icons/feather-icon/feather.min.js"></script>
    <script src="assets/js/icons/feather-icon/feather-icon.js"></script>
    <!-- Sidebar jquery-->
    <script src="assets/js/sidebar-menu.js"></script>
    <script src="assets/js/config.js"></script>
    <!-- Plugins JS start-->
    <!-- Plugins JS Ends-->
    <!-- Theme js-->
    <script src="assets/js/script.js"></script>
    <!-- Plugin used-->
  </body>
</html>