<?php
  include '../db.php';

  if(isset($_POST["username"])){

    $user = $db->getRow("select * from tbl_info where userid='$_POST[username]' and password='$_POST[password]' ");
      if(count($user)>1){

          $_SESSION["first"] = "yes";
          $_SESSION["superadmin"]["uid"]=$user["id"];

          // redirect("./index.php");
          header( "refresh:0; url=index.php");

      } else {
          $_SESSION["msg"] = "Invalid credentials";
      }
  }

?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Admin Login</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  <!-- <script src="../assets/js/login.js"></script> -->
  <link rel="stylesheet" href="../assets/css/admin-style.css">
</head>
<body>

<!-- Section: Design Block -->
<style>
    section {
      height:750px;
    }
    .background-radial-gradient {
      background-color: hsl(218, 41%, 15%);
      background-image: radial-gradient(650px circle at 0% 0%,
          hsl(218, 41%, 35%) 15%,
          hsl(218, 41%, 30%) 35%,
          hsl(218, 41%, 20%) 75%,
          hsl(218, 41%, 19%) 80%,
          transparent 100%),
        radial-gradient(1250px circle at 100% 100%,
          hsl(218, 41%, 45%) 15%,
          hsl(218, 41%, 30%) 35%,
          hsl(218, 41%, 20%) 75%,
          hsl(218, 41%, 19%) 80%,
          transparent 100%);
    }

    #radius-shape-1 {
      height: 220px;
      width: 220px;
      top: -60px;
      left: -130px;
      background: radial-gradient(#44006b, #ad1fff);
      overflow: hidden;
    }

    #radius-shape-2 {
      border-radius: 38% 62% 63% 37% / 70% 33% 67% 30%;
      bottom: -60px;
      right: -110px;
      width: 300px;
      height: 300px;
      background: radial-gradient(#44006b, #ad1fff);
      overflow: hidden;
    }

    .bg-glass {
      background-color: hsla(0, 0%, 100%, 0.9) !important;
      backdrop-filter: saturate(200%) blur(25px);
      height:500px;
    }
  </style>

<section class="background-radial-gradient overflow-hidden">
  
  <div class="container px-4 py-5 px-md-5 text-center text-lg-start my-5">
    <div class="row gx-lg-5 align-items-center mb-5">
      <div class="col-lg-6 mb-5 mb-lg-0" style="z-index: 10">
        <h1 class="my-5 display-5 fw-bold ls-tight" style="color: hsl(218, 81%, 95%)">
          The best offer <br />
          <span style="color: hsl(218, 81%, 75%)">for your business</span>
        </h1>
        <p class="mb-4 opacity-70" style="color: hsl(218, 81%, 85%)">
          Lorem ipsum dolor, sit amet consectetur adipisicing elit.
          Temporibus, expedita iusto veniam atque, magni tempora mollitia
          dolorum consequatur nulla, neque debitis eos reprehenderit quasi
          ab ipsum nisi dolorem modi. Quos?
        </p>
      </div>

      <div class="col-lg-6 mb-5 mb-lg-0 position-relative">
        <div id="radius-shape-1" class="position-absolute rounded-circle shadow-5-strong"></div>
        <div id="radius-shape-2" class="position-absolute shadow-5-strong"></div>

        <div class="card bg-glass">
          <div class="card-body px-4 py-5 px-md-5">
            <form id="myForm" method="post">
              <!-- 2 column grid layout with text inputs for the first and last names -->
              <div class="row">
                <h3 class="text-center mb-5"  style="color:navy">Please login to your account</h3>
                <div class="col-md-12 mb-4">
                  <div class="form-outline">
                    <label class="form-label" >Username</label>  
                    <input type="text" name="username" class="form-control" />                    
                  </div>
                </div>

              <!-- Password input -->
              <div class="form-outline mb-4">
                <label class="form-label" >Password</label>  
                <input type="password" name="password" class="form-control" />                
              </div>

              <?php if($_SESSION["msg"]){ ?>
              <div id="error" style="color:red;text-align:center;"><?php echo $_SESSION["msg"]; ?></div>
              <?php unset($_SESSION["msg"]); } ?>

              <!-- Submit button -->
              <button type="submit" class="btn btn-primary btn-block mt-5 mb-4 mx-auto">
                Login
              </button>

            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
<!-- Section: Design Block -->


</body>
</html>
