<!DOCTYPE html>
<html lang="en">

<?php
require_once "config.php";

if (isset($_SESSION['user_id'])) {
    echo "<script>location.href='myProfile';</script>";
}

$query = mysqli_query($db, "SELECT * FROM `reset_password_key` WHERE `key`='$_GET[key]' ");
$resetCount = mysqli_num_rows($query);
$reset = mysqli_fetch_assoc($query);
if ($resetCount == 0) {
    echo "<script>alert('This Link is Invalid, Please Contact Your Manager or Boss !');</script>";
    echo "<script>location.href='index';</script>";
    exit();
}

?>

<head>
    <meta charset="utf8" />
    <title>Employee - Jobaaj </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
    <meta content="Coderthemes" name="author" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Favicon -->
    <link rel="shortcut icon" href="https://cdn.nishtyainfotech.com/content/jobaaj/assets/img/jobaaj-favicon.ico">

    <!-- App css -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />

</head>

<body class="authentication-bg">

    <div class="account-pages my-5">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-body p-5">
                            <div class="mx-auto mb-2 text-center">
                                <a href="javascript:;" class="text-center">
                                    <img src="https://cdn.nishtyainfotech.com/content/jobaaj/assets/svg/logos/jobaaj1.png" alt="" width="100" />
                                    <!-- <h3 class="d-inline align-middle ml-1 text-logo">Jobaaj</h3> -->
                                </a>
                            </div>

                            <h6 class="h5 mb-0">Welcome back!</h6>
                            <p class="text-muted mt-1 mb-4">Reset password and access admin panel.</p>

                            <form action="fun/user_login.php" method="post" enctype="multipart/form-data" class="authentication-form">

                                <input type="hidden" name="resetKey" value="<?php echo $reset['key']; ?>">
                                <input type="hidden" name="employee_id" value="<?php echo $reset['employee_id']; ?>">
                                <div class="form-group mt-3">
                                    <label class="form-control-label">Password</label>
                                    <div class="input-group input-group-merge">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text">
                                                <i class="icon-dual" data-feather="lock"></i>
                                            </span>
                                        </div>
                                        <input type="password" name="password" class="form-control" id="password" placeholder="Enter your password" required>
                                    </div>
                                </div>

                                <div class="form-group mt-3">
                                    <label class="form-control-label">Confirm Password</label>
                                    <div class="input-group input-group-merge">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text">
                                                <i class="icon-dual" data-feather="lock"></i>
                                            </span>
                                        </div>
                                        <input type="password" name="cPassword" class="form-control" id="cPassword" placeholder="Confirm your password" required>
                                    </div>
                                </div>

                                <div class="form-group mb-0 text-center">
                                    <button class="btn btn-primary btn-block" name="resetPassword" type="submit">Reset</button>
                                </div>
                            </form>
                        </div> <!-- end card-body -->
                    </div>
                    <!-- end card -->

                </div> <!-- end col -->
            </div>
            <!-- end row -->
        </div>
        <!-- end container -->
    </div>
    <!-- end page -->

    <!-- Vendor js -->
    <script src="assets/js/vendor.min.js"></script>

    <!-- App js -->
    <script src="assets/js/app.min.js"></script>

</body>

</html>