<?php 
include("db_connection.php");

$msg="";
if(isset($_POST['submit']))
{

	$email=$_POST['email'];
	
	$password=$_POST['password'];
	
	
	$sql=mysql_query("select * from admin_login where aemail='$email' and apassword='".md5($password)."'");
	
	$res=mysql_fetch_assoc($sql);
	
	if(isset($res['aname']))
	{
	
	

		if(isset($_POST['checkbox']))
		{
			setcookie("Log_username", $email, time() + (10 * 365 * 24 * 60 * 60));
		
			setcookie('Log_password', $password, time()+ (10 * 365 * 24 * 60 * 60));
			
			setcookie('Log_check', $_POST['checkbox'], time()+ (10 * 365 * 24 * 60 * 60));
		}
		else
		{
			
			//setcookie('Log_username', '', time()-300);
			setcookie("Log_username", $email, time()-1);
    		setcookie("Log_password", $password, time()-1);
			setcookie("Log_check", $_POST['checkbox'], time()-1);
			
			
		}
		
		$_SESSION['aid']=$res['aid'];
		$_SESSION['aname']=$res['aname'];
		$_SESSION['aemail ']=$res['aemail'];
		
		?>
		<script>
        window.location="dashboard.php";
        </script>
		<?php
		
		
	}
	else
	{
		$msg="Email Or Password Does Not Match";
		
		setcookie("Log_username", $email, time()-1);
		setcookie("Log_password", md5($password), time()-1);
		setcookie("Log_check", $_POST['checkbox'], time()-1);
	}
	
	
}
$upass="";$uname="";$ucheck="";
if(isset($_COOKIE['Log_username']) && isset($_COOKIE['Log_password']))
{
	
	$uname=$_COOKIE['Log_username'];
	$upass=$_COOKIE['Log_password'];
	$ucheck=$_COOKIE['Log_check'];
}

//echo'<pre>';print_r($_COOKIE);


?>

<!DOCTYPE html>
<html class="no-js before-run" 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.0, user-scalable=0, minimal-ui">
  <meta name="description" content="bootstrap admin template">
  <meta name="author" content="">

  <title>Login | OlxClone</title>

  <link rel="apple-touch-icon" href="assets/images/apple-touch-icon.png">
  <link rel="shortcut icon" href="assets/images/favicon.ico">

  <!-- Stylesheets -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/css/bootstrap-extend.min.css">
  <link rel="stylesheet" href="assets/css/site.min.css">

  <link rel="stylesheet" href="assets/vendor/animsition/animsition.css">
  <link rel="stylesheet" href="assets/vendor/asscrollable/asScrollable.css">
  <link rel="stylesheet" href="assets/vendor/switchery/switchery.css">
  <link rel="stylesheet" href="assets/vendor/intro-js/introjs.css">
  <link rel="stylesheet" href="assets/vendor/slidepanel/slidePanel.css">
  <link rel="stylesheet" href="assets/vendor/flag-icon-css/flag-icon.css">


  <!-- Page -->
  <link rel="stylesheet" href="assets/css/pages/login.css">

  <!-- Fonts -->
  <link rel="stylesheet" href="assets/fonts/web-icons/web-icons.min.css">
  <link rel="stylesheet" href="assets/fonts/brand-icons/brand-icons.min.css">
  <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Roboto:300,400,500,300italic'>


  <!--[if lt IE 9]>
    <script src="assets/vendor/html5shiv/html5shiv.min.js"></script>
    <![endif]-->

  <!--[if lt IE 10]>
    <script src="assets/vendor/media-match/media.match.min.js"></script>
    <script src="assets/vendor/respond/respond.min.js"></script>
    <![endif]-->

  <!-- Scripts -->
  <script src="assets/vendor/modernizr/modernizr.js"></script>
  <script src="assets/vendor/breakpoints/breakpoints.js"></script>
  <script>
    Breakpoints();
  </script>
</head>
<body class="page-login layout-full">
  <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->


  <!-- Page -->
  <div class="page animsition vertical-align text-center" data-animsition-in="fade-in"
  data-animsition-out="fade-out">>
    <div class="page-content vertical-align-middle">
      <div class="brand">
        <img class="brand-img" src="assets/images/logo.png" alt="...">
        <!--<h2 class="brand-text">Exchage Kar DE</h2>-->
      </div>
      <p>Sign into your account</p>
      <?php 
	  if($msg==!"")
	  {
		  ?>
		  	<div class="alert alert-danger alert-dismissible" role="alert">
                  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">×</span>
                  </button>
                 <?php echo $msg;?>
                </div>
		  <?php
	  }
	  ?>
      
      <form method="post">
       <!-- <div class="form-group">
          <label class="sr-only" for="inputName">Name</label>
          <input type="text" class="form-control" id="inputName" placeholder="Name">
        </div>-->
        <div class="form-group">
          <label class="sr-only" for="inputEmail">Email</label>
          <input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" value="<?php echo $uname;?>">
        </div>
        <div class="form-group">
          <label class="sr-only" for="inputPassword">Password</label>
          <input type="password" class="form-control" id="inputPassword" name="password"
          placeholder="Password" value="<?php echo $upass;?>">
        </div>
        <div class="form-group clearfix">
          <div class="checkbox-custom checkbox-inline pull-left">
            <input <?php if($ucheck=="on") { echo "checked='checked'";} ?>type="checkbox" id="inputCheckbox" name="checkbox">
            <label for="inputCheckbox">Remember me</label>
          </div>
         <!--<a class="pull-right" href="forgot-password.php">Forgot password?</a>-->
        </div>
        <button type="submit" name="submit" class="btn btn-primary btn-block">Sign in</button>
      </form>
      <!--<p>Still no account? Please go to <a href="register.html">Register</a></p>-->

      <footer class="page-copyright">
        <p>WEBSITE BY Phpscriptsonline.com</p>
        <p>© 2017. All RIGHT RESERVED.</p>
        <div class="social">
          <a href="javascript:void(0)">
            <i class="icon bd-twitter" aria-hidden="true"></i>
          </a>
          <a href="javascript:void(0)">
            <i class="icon bd-facebook" aria-hidden="true"></i>
          </a>
          <a href="javascript:void(0)">
            <i class="icon bd-dribbble" aria-hidden="true"></i>
          </a>
        </div>
      </footer>
    </div>
  </div>
  <!-- End Page -->


  <!-- Core  -->
  <script src="assets/vendor/jquery/jquery.js"></script>
  <script src="assets/vendor/bootstrap/bootstrap.js"></script>
  <script src="assets/vendor/animsition/jquery.animsition.js"></script>
  <script src="assets/vendor/asscroll/jquery-asScroll.js"></script>
  <script src="assets/vendor/mousewheel/jquery.mousewheel.js"></script>
  <script src="assets/vendor/asscrollable/jquery.asScrollable.all.js"></script>
  <script src="assets/vendor/ashoverscroll/jquery-asHoverScroll.js"></script>

  <!-- Plugins -->
  <script src="assets/vendor/switchery/switchery.min.js"></script>
  <script src="assets/vendor/intro-js/intro.js"></script>
  <script src="assets/vendor/screenfull/screenfull.js"></script>
  <script src="assets/vendor/slidepanel/jquery-slidePanel.js"></script>

  <script src="assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>

  <!-- Scripts -->
  <script src="assets/js/core.js"></script>
  <script src="assets/js/site.js"></script>

  <script src="assets/js/sections/menu.js"></script>
  <script src="assets/js/sections/menubar.js"></script>
  <script src="assets/js/sections/sidebar.js"></script>

  <script src="assets/js/configs/config-colors.js"></script>
  <script src="assets/js/configs/config-tour.js"></script>

  <script src="assets/js/components/asscrollable.js"></script>
  <script src="assets/js/components/animsition.js"></script>
  <script src="assets/js/components/slidepanel.js"></script>
  <script src="assets/js/components/switchery.js"></script>
  <script src="assets/js/components/jquery-placeholder.js"></script>

  <script>
    (function(document, window, $) {
      'use strict';

      var Site = window.Site;
      $(document).ready(function() {
        Site.run();
      });
    })(document, window, jQuery);
  </script>

</body>

</html>