<?php
    session_start();
?>

<!doctype html>
<html lang="en" dir="ltr">

<!-- soccer/project/login.html  07 Jan 2020 03:42:43 GMT -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link rel="icon" href="favicon.ico" type="image/x-icon"/>

<title> Login</title>

<!-- Bootstrap Core and vandor -->
<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css" />

<!-- Core css -->
<link rel="stylesheet" href="assets/css/main.css"/>
<link rel="stylesheet" href="assets/css/theme1.css"/>

</head>
<body class="font-montserrat">


<div class="auth">
    <div class="auth_left">
        <form method="post" class="card">
            <div class="text-center mb-2">
                <a class="header-brand" href="/">
                    <img src="myassets/images/sydney-logo-new.png" width="75%"/>
                </a>
            </div>
            <div class="card-body">
                <div class="card-title">Login to your account</div>
            
                <div class="form-group">
                    <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="username" placeholder="Enter email">
                </div>
                <div class="form-group">
                    <label class="form-label">Password<a href="forgot-password.html" class="float-right small">I forgot password</a></label>
                    <input type="password" class="form-control" id="exampleInputPassword1" name="pass" placeholder="Password">
                </div>
                <div class="form-group">
                    <label class="custom-control custom-checkbox">
                    <input type="checkbox" class="custom-control-input" />
                    <span class="custom-control-label">Remember me</span>
                    </label>
                </div>
                <div class="form-footer">
                    <!--<a href="index-2.html" class="btn btn-primary btn-block" title="">Sign in</a>-->
                    <button type="submit" class="btn btn-primary btn-block signin" name="signinbtn">sign in</button>
                </div>
            </div>
            <div class="text-center text-muted">
                Don't have account yet? <a href="register.html">Sign up</a>
            </div>
        </form>        
    </div>
    <div class="auth_right full_img"></div>
</div>


<script src="assets/bundles/lib.vendor.bundle.js"></script>
<script src="assets/js/core.js"></script>
</body>

<!-- soccer/project/login.html  07 Jan 2020 03:42:43 GMT -->
</html>







<?php
include("../myclass.php");
$obj = new myclass();

if (isset($_POST['signinbtn'])) {
    $u= $_POST['username'];
    $p= $_POST['pass'];

    $c = $obj->login($u, $p);

    $ecus = mysqli_fetch_array($c);
    if (mysqli_num_rows($c) > 0) {

        $_SESSION['admin_id'] = $ecus['id'];

        echo "<script>window.location.assign('blogs.php');</script>";
       
    } else {
        echo "<script>alert('Credentials Not Match our records');</script>";
    }

}

?>


<script>
    document.querySelectorAll(".fa-eye").forEach((eye) => {
  eye.addEventListener("click", () => {
    const passwordInput = eye.previousElementSibling;

    if (passwordInput.type === "password") {
      passwordInput.type = "text";
      eye.classList.remove("fa-eye");
      eye.classList.add("fa-eye-slash");
    } else {
      passwordInput.type = "password";
      eye.classList.remove("fa-eye-slash");
      eye.classList.add("fa-eye");
    }
  });
});
</script>
