<?php session_start();
require_once 'inc/dbcon.php';
require_once 'inc/functions.php';
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
if(isset($_SESSION['cuPages'])){
$cuPage='pages/'.$_SESSION['cuPages'];    
}else{
$cuPage='index.php';    
}
header('Location:'.$cuPage);
exit;    
}
$phead='login';
include('layout/head.php');
?>
<body class="loginbg">
<div class="wrapper">
<div class="login-box" style=" margin-bottom: 5px;">
<div class="login-logo">
<img src="img/axes.png" />
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<?php if(isset($_SESSION['errmsg']) && $_SESSION['errmsg']!=''){?>
<p class="text-red text-center"><?php echo $_SESSION['errmsg'];?></p>    
<?php } ?>  
<form action="inc/login.php" autocomplete="off" method="post" accept-charset="utf-8">
<div class="form-group has-feedback">
<input type="email" name="email" class="form-control" value="<?php if(ISSET($_COOKIE['username'])){echo $_COOKIE['username'];}else{echo '';}?>" placeholder="Email" required>
<span class="fa fa-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" value="<?php if(ISSET($_COOKIE['password'])){echo $_COOKIE['password'];}?>" placeholder="Password" required>
<span class="fa fa-lock form-control-feedback"></span>
</div>
<div class="row">

<div class="col-xs-8 ">
<label class="checkbox"><input type="checkbox" value="1" name="remember" class="remember" <?php if(ISSET($_COOKIE['username'])){echo 'checked';}?>> Remember Me.</label>   
</div>
<!-- /.col -->
<div class="col-xs-4 text-right">
<button type="submit" name="login" class="btn btn-flat bg-purple btn-sm">Sign In</button>
</div>
</div>    
</form>                        
    <!-- /.col -->
<div class="row">    
<div class="col-xs-12 text-right">
<br><a onclick="$('.forgotpassword').toggle()" href="#" >Forgot password ?</a>
</div>
<div class="col-xs-12 forgotpassword" style="display: none">
<div class="form-group">
<label>Enter Your Email</label>
<input type="text" class="form-control forgot_email" name="forgot_email" value=""/>
</div>
<div class="form-group">
<input type="button" class="btn btn-flat bg-purple btn-sm" name="submit" value="Submit" onclick="forgot_password()" />
</div>
</div>
</div>                    
<!-- /.social-auth-links -->
</div>
<!-- /.login-box-body -->
</div>
</div>
<div  class="modal fade modal-msg" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header ">
<h4 class="modal-title">Alert</h4>
</div>
<div class="modal-body" ><p></p></div>
<div class="modal-footer">
<a class="btn btn-flat bg-purple" data-dismiss="modal" aria-label="Close">OK</a>
</div>
</div>
</div>
</div>
<?php 
if(isset($_SESSION['errmsg'])){
unset($_SESSION['errmsg']);    
}    
?>    
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!--iCheck-->
<link rel="stylesheet" href="plugins/icheck/all.css">
<script src="plugins/icheck/icheck.min.js"></script>
<script>

$(document).ready(function () {
$('.remember').iCheck({checkboxClass: 'icheckbox_minimal-blue', cursor: true, });
});
function forgot_password() {
var email = $('.forgot_email').val();
$.ajax({
type: "POST",
url: "inc/forget.php",
cache: false,
data: {'email': email},
dataType: 'json',
timeout: 15000,
success: function (data)
{
if (data['success']) {
toaster(data['message']);
setTimeout(function () {
location.reload(true);
}, 2000);

} else {
toaster(data['message']);
}

},
error: function (jqXHR, textStatus, errorThrown) {

}
});
}
function toaster(msg) {
if (msg)
$('.modal-msg .modal-body p').text(msg);
$('.modal-msg').modal({backdrop: 'static', keyboard: false});
}
</script>
</body>
</html>
