<?php
session_start();
include_once('connection.php');
if($_COOKIE["adminLogAdmin"] == ''){}else{
	header("Location: index.php");
	exit();
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        <title>Login</title>
        <link href="css/styles.css" rel="stylesheet" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js" crossorigin="anonymous"></script>
    </head>
    <body class="bg-primary">
        <div id="layoutAuthentication">
            <div id="layoutAuthentication_content">
                <main>
                    <div class="container">
                        <div class="row justify-content-center">
                            <div class="col-lg-5">
                                <div class="card shadow-lg border-0 rounded-lg mt-5">
                                    <div class="card-header"><h3 class="text-center font-weight-light my-4">Login</h3></div>
                                    <div class="card-body">
                                        <form name="frm_enquiry" action="" method="post" onSubmit="return false" id="frm_enquiry">
                                            <div class="form-group mb-3">
                                            	 <label for="inputEmail">Email address</label>
                                                <input class="form-control" id="inputEmail" type="email" name="username" placeholder="name@example.com" />
                                            </div>
                                            <div class="form-group mb-3">
                                            	<label for="inputPassword">Password</label>
                                                <input class="form-control" id="inputPassword" name="password"  type="password" placeholder="Password" />
                                                
                                            </div>
                                            <div class="form-check mb-3">
                                                <div id="message_sent" class="text-danger text-center"></div>
                                            </div>
                                           <div class="d-flex align-items-center justify-content-between mt-4 mb-0">
                                                <button type="submit" class="btn btn-primary" id="submit_button" >Login</button>
                                                
                                            </div>
                                        </form>
										<div id="message_sent" class="text-danger d-block mt-3"></div>
                                    </div>
                                   
                                </div>
                            </div>
                        </div>
                    </div>
                </main>
            </div>
            <div id="layoutAuthentication_footer">
                <footer class="py-4 bg-light mt-auto">
                    <div class="container-fluid px-4">
                        <div class="d-flex align-items-center justify-content-between small">
                            <div class="text-muted">Copyright &copy; Your Website 2021</div>
                            <div>
                                <a href="#">Privacy Policy</a>
                                &middot;
                                <a href="#">Terms &amp; Conditions</a>
                            </div>
                        </div>
                    </div>
                </footer>
            </div>
        </div>
        <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
        <script src="js/scripts.js"></script>
		
<script>
$(document).ready(function(){
	$("#submit_button").click(function(){
	var t = Date.now();
	var datas=$("#frm_enquiry").serialize();
	$("#submit_button").attr('disabled','disabled');
		$.ajax({
			type:"POST",
			url:"login-process.php",
			data:datas,
			success:function(data)
			{
				if(data=='success'){
					
						//window.alert('Login Succesfully'); 
						window.location.href='index.php?t='+t; 
						
						}else{
							$("#message_sent").fadeTo(200,0.1,function()
							{$("#submit_button").attr('disabled',false);
							$("#message_sent").html(data).fadeTo(900,1,function(){});
							});
					 }
			}
		});
	  });
	});
</script>
		
		
    </body>
</html>
