<?php 
session_start();
include '../db.php';
include '../config.php';
include '../functions.php';
?>
<!DOCTYPE html>
<html lang="en">


<!-- Mirrored from quomodosoft.com/html/bankcohtml/sign-in.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 04 Jan 2025 01:45:36 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> <?php echo $sitename ?></title>

    <!-- fave-icon  -->
    <link rel="shortcut icon" href="assets/images/icon/fave-icon.png" type="image/png">

    <link href="https://fonts.googleapis.com/css2?family=Urbanist:wght@300;400;500;600;700;900&amp;display=swap"
        rel="stylesheet">

    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/slick.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/responsive.css">

</head>
<?php
    $msg = "";
    
    $username_err = $password_err= ""; 
    $username = $password= "";
        
        if (isset($_POST['submit'])) {
            
             if (empty($_POST["username"])) {
                $username_err = "username is required";
              } else {
                $username = test_input($_POST["username"]);
                // check if e-mail address is well-formed
                
              }
              
              if (empty($_POST["password"])) {
                $password_err = "Password is required";
              } else {
                $password = test_input($_POST["password"]);
                // check if name only contains letters and whitespace
              }
    
            if($username == "" || $password == ""){
                $msg = "Username or Password fields cannot be empty!";
            }else{
                $sql = mysqli_query($link, "SELECT id, username, password FROM admin WHERE username='$username' AND password= '$password'");
                if(mysqli_num_rows($sql) > 0){
                    $data = mysqli_fetch_assoc($sql);
                    $_SESSION['ADMINID'] = $data['id'];
    
                    // header("location: dashboard.php");
                    echo "<script>window.location.href = 'dashboard.php' </script>";
    
                    
                }else{
                    $msg = "Invalid Username and Password";
                }
            }
        }
    
        function test_input($data) {
          $data = trim($data);
          $data = stripslashes($data);
          $data = htmlspecialchars($data);
          return $data;
    }
    
?>
<body>
    <div class="sign-up-top">

        <div class="sign-up-main">
            <div class="sign-up-logo">
                <img src="logo.png" alt="logo" width="100">
            </div>
            <div class="sign-up-text">
                <h2>Welcome  Admin</h2>
            </div>

            <div class="sign-up-from">
                <div class="sign-up-from-item">
                    <form action="" method="post">
                    <div class="sign-up-from-inner">
                        <input type="text" name="username" class="form-control" id="exampleFormControlInput"
                            placeholder="Username">
                    </div>
                    <div class="sign-up-from-inner">
                        <input type="password" class="form-control" name="password" id="exampleFormControlInput1" placeholder="Password">

                        
                    </div>

            
                    <div class="sign-up-btn">
                      
                            <button class="btn-one" name="submit">SIGN IN</button>
                 
                    </div>

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

        </div>
        <div class="sign-up-main-two">

            <div class="sign-up-main-two-item">
                <div class="sign-up-img">
                    <img src="assets/images/sign-up.svg" alt="img">
                </div>

                <!--<div class="sign-up-main-two-item-text">-->
                <!--    <h2>Speady, Easy and Fast</h2>-->
                <!--    <p>BankCo. help you set saving goals, earn cash back offers, Go to disclaimer for more details and-->
                <!--        get paychecks up to two days early. Get a $20 bonus when you receive qualifying direct deposits-->
                <!--    </p>-->
                <!--</div>-->
            </div>


        </div>

    </div>



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