
<?php 
include ('../functions.php');
?>

<html>
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    
    <style>
    .gradient-custom-3 {
/* fallback for old browsers */
background: #84fab0;

/* Chrome 10-25, Safari 5.1-6 */
background: -webkit-linear-gradient(to right, rgba(132, 250, 176, 0.5), rgba(143, 211, 244, 0.5));

/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background: linear-gradient(to right, rgba(132, 250, 176, 0.5), rgba(143, 211, 244, 0.5))
}
.gradient-custom-4 {
/* fallback for old browsers */
background: #84fab0;

/* Chrome 10-25, Safari 5.1-6 */
background: -webkit-linear-gradient(to right, rgba(132, 250, 176, 1), rgba(143, 211, 244, 1));

/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background: linear-gradient(to right, rgba(132, 250, 176, 1), rgba(143, 211, 244, 1))
}
</style>







 





    
    
<section class="vh-100 bg-image"
  style="background-image: url('https://mdbcdn.b-cdn.net/img/Photos/new-templates/search-box/img4.webp');">
  <div class="mask d-flex align-items-center h-100 gradient-custom-3">
    <div class="container h-100">
      <div class="row d-flex justify-content-center align-items-center h-100">
        <div class="col-12 col-md-9 col-lg-7 col-xl-6">
          <div class="card" style="border-radius: 15px;">
            <div class="card-body p-5">
              <h2 class="text-uppercase text-center mb-5">LOGIN account</h2>
              
              
              
              
            <?php 
                                if (isset($_POST['login_admin'])) {
                                    $username = trim($_POST['username']);
                                    $password = trim($_POST['password']);
                                    $ChkUser = $connect->query("SELECT * FROM administrators WHERE username='$username'");

                                    if (empty($username) AND empty($password)) {
                                        echo "<span class='text-danger'><strong>All Fields are Required!</strong></span>";
                                    }elseif ($ChkUser->num_rows > 0) {
                                        foreach ($ChkUser as $key => $value) {
                                            if ($value['password'] == $password) {
                                                setcookie("isLoggedIn", $username, time()+3600);
                                                echo "<span><strong class='text-success'>Logged in Successfully! Redirecting to Dashboard</strong></span>";
                                                header("refresh:3, url=home.php");
                                            }else{
                                                echo "<span class='text-danger'><strong>Check Password and Try Again!</strong></span>";
                                            }
                                        }
                                    }else{
                                        echo "<span class='text-danger'><strong>Invalid Details!</strong></span>";
                                    }
                                }
                                ?>
              

              <form method="POST">

              
                
                 <div class="form-outline mb-4">
                  <input type="" id="form3Example3cg" name="username" class="form-control form-control-lg" />
                  <label class="form-label" for="form3Example3cg">Your Username</label>
                </div>

                <div class="form-outline mb-4">
                  <input type="password" id="form3Example4cg" name="password" class="form-control form-control-lg" />
                  <label class="form-label" for="form3Example4cg">Password</label>
                </div>

             
              
                <div class="d-flex justify-content-center">
                  <button type="submit" name="login_admin"
                    class="btn btn-success btn-block btn-lg gradient-custom-4 text-body">Login</button>
                </div>



              </form>

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



</html>