<?php session_start(); ?>
<?php 
	include "database.php";
	if(isset($_SESSION['admin_id'])){
		echo '<script> window.location.href = "index.php"; </script>';
		header("location:index.php");
		exit();
	}
?>
<?php
	$error = "";
	if(isset($_POST['admin_login'])){
		$admin_email = $_POST['admin_email'];
		$admin_password = $_POST['admin_password'];
		$result = mysqli_query($con,"SELECT * FROM admin WHERE admin_email='$admin_email' AND admin_password='$admin_password'");
		if(mysqli_num_rows($result)>0){
			$row = mysqli_fetch_array($result);
			$_SESSION['admin_id']= $row['admin_id'];
			$_SESSION['role'] = $row['role'];
			$role = $_SESSION['role'] ;
			if($role=='Super Admin'){$role='super admin';}elseif($role=='User'){$role='user';}
			echo '<script> window.location.href = "index.php"; </script>';
			header("location:index.php"); exit();
		} else {
			$error = '<p style="padding:15px; color:red;font-weight:bold;text-align:center"><b>Invalid Email or Password</b></p>';
		}
	}
	
	$res = mysqli_query($con, "SELECT * FROM system_configuration");
	$lang = mysqli_fetch_array($res);
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<title>Forget Password</title>
    <?php include "includes/headerlinks.php";?>
    <style>
		.login-register {
			height: 100vh !important;
		}
		@media only screen and (max-width: 600px) {
		  .login-box {
			height: 370px !important;
			position:relative;
			top:70px;
		  }
		}
	</style>
</head>

<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <section id="wrapper" class="login-register login-sidebar" style="background-image:url(assets/images/background/ezgif.com-webp-to-jpg.jpg);">
        <div class="login-box card">
            <div class="card-body">
                <form class="form-horizontal form-material" id="" method="post">
                    <a href="javascript:void(0)" class="text-center db"><img src="uploads/logo/<?php echo $lang['system_image']?>" alt="Home" style="width:40%;margin-top:0px"></a>
                    <?php echo $error;?>
					<br><div class="form-group ">
                        <div class="col-xs-12">
                            <h3>Recover Password</h3>
                            <p class="text-muted">Enter your Email and instructions will be sent to you! </p>
                        </div>
                    </div>
                    <div class="form-group ">
                        <div class="col-xs-12">
                            <input class="form-control" type="text" required="" placeholder="Email">
                        </div>
                    </div>
					<div class="form-group text-center m-t-20">
                        <div class="col-xs-12">
                            <button class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light" name="admin_login" type="submit" style="background:#df0008 !important;border-color:#df0008 !important">Reset</button>
                        </div>
                    </div>
                    <div class="form-group m-b-0">
                        <div class="col-sm-12 text-center">
                            <p><a href="login.php" class="text-primary m-l-5"  style="color:#67757c !important;margin-left:-10px">Back to Login	</a></p>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
    <?php include "includes/footerlinks.php";?>
</body>

</html>