<?php
include_once "includes/connectConfig.php";
only_login($log_session)
?>
<!DOCTYPE html>
	<head>

		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>LOGIN ADMIN | K-MART</title>
		<link rel="shortcut icon" type="image/x-icon" href="img/kmart-icon.png" />

		<link rel="stylesheet" type="text/css" href="log_reg/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="log_reg/css/style.css">

	</head>
	<body>
	  <div class="home">
	  <div class="wrapper">
		 <div class="title">
			<img class="img-fluid" src="img/kmart-logo.png" alt="K-Mart logo" width="45%"/>
			
			<span class="d-block bl_cl">Login Form</span>
		 </div>
		 
		 <h6 class="errors_here bg-white"  id="errors_here"></h6>
		 
		 <form method="POST"  id="entlogz"  autocomplete="false"  enctype="multipart/form-data">
			
			<div class="acerr">
			   <input  type="text" name="lgzemail" required >
			   <label>Email Address</label>
			   
			   <span class="errac"></span>
			</div>
			
			<div class="acerr">
			   <input type="password" name="lgzpassword" required >
			   <label>Password</label>
			   
			   <span class="errac"></span>
			</div>
			<?php /*<div class="content">
			   <div class="checkbox">
				  <input type="checkbox" id="remember-me">
				  <label for="remember-me">Remember me</label>
			   </div>
			   <div class="pass-link">
				  <a href="#">Forgot password?</a>
			   </div>
			</div>*/ ?>
			<div class="acerr mt-5">
			   <input type="submit" id="tkstsubm" value="Login">
			</div>
			<?php /*<div class="signup-link">
			   Not a member? <a href="#">Signup now</a>
			</div>*/ ?>
		 </form>
	  </div>
	  </div>
	  
	<script src="log_reg/js/jquery-3.1.1.min.js"></script>
	<script src="log_reg/js/popper.min.js"></script>
	<script src="log_reg/js/bootstrap.min.js"></script>
	
<script type="text/javascript">
	
$('document').ready(function()
{ 		 		
	var eregex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	$.validator.addMethod("validemail", function( value, element ) { return this.optional( element ) || eregex.test( value ); }); 
	$("#entlogz").validate({
	rules: {  lgzemail: {required: true,validemail: true}, lgzpassword: {required: true} },
	messages: {lgzemail: { required: "Enter Email", validemail: "Invalid Email" }, lgzpassword:{ required: "Enter Password"} },
	errorPlacement : function(error, element) { $(element).closest('.acerr').find('.errac').html(error.html()); },
	highlight : function(element) { $(element).closest('.acerr').removeClass('has-success').addClass('has-error'); },
	unhighlight: function(element, errorClass, validClass) {
	$(element).closest('.acerr').removeClass('has-error').addClass('has-success');
	$(element).closest('.acerr').find('.errac').html(''); },
	submitHandler: submitForm
	}); 
	function submitForm(){
	var data = $("#entlogz").serialize();
	$.ajax({
	type : 'POST',url  : 'actions/accnlogz.php', data : data,
	beforeSend: function(){	$('#errors_here').html(''); $('#tkstsubm').attr('disabled', 'disabled'); $('#tkstsubm').val('Validating ....'); },
	dataType:"json", success :  function(data){				
	$('#errors_here').html('');
	if(data.gerr != ""){
	if(data.gerr == "invalid"){ $('#errors_here').html('Invalid details');} else { $('#errors_here').html(data.loadcheckout); }
	$('#tkstsubm').attr('disabled', false); $('#tkstsubm').val('Login'); }
	else{ $("#tkstsubm").val('Loading page ...'); $("#entlogz").trigger('reset'); window.location.href = data.loadpage; }
	}  }); return false;  }
});
</script>

<script src="log_reg/js/validation.min.js" type="text/javascript"></script>
<script src="log_reg/js/jquery.validate.min.js"></script>

	</body>
</html>