<?php 
include("db_connection.php");
$msg="";
if(isset($_POST['change']))
{

	$password=md5($_POST['password']);
	
	mysql_query("upadte admin_login set apassword='$password' where aid='".$_SESSION['aid']."'");
	
	
	$msg="Password Changed Successfully";
	
	?>
	<script>
	setTimeout(function(){
		document.location = 'logout.php';
	},3000);
	</script>
	<?php
}


?>
<!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>Forgot password | Remark Admin Template</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/forgot-password.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-forgot-password 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">
       <?php 
	  if($msg!=="")
	  {
		  ?>
		  	<div class="alert alert-info alert-dismissible" role="alert">
                  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                  <?php echo $msg;?>
                </div>
		  <?php
	  }
	  ?>
      <h2 class="page-title">Change Your Password ?</h2>
     
      <form class="width-300 margin-top-30 center-block" method="post">
        <div class="form-group">
          <input type="password" class="form-control" required id="inputEmail" name="old_password" placeholder="Old Password">
          <h5 id="checkoldp" class="pull-left"></h5>
        </div>
        
        
         <div class="form-group">
          <input type="password" class="form-control" required id="inputEmail" name="password" placeholder="New Password">
        </div>
         <div class="form-group">
          <input type="password" class="form-control" required id="inputEmail" name="confirm_password" placeholder="Confirm Password">
        </div>
        <h5 id="matchP" class="pull-left"></h5>
        <div class="form-group">
          <button type="submit" name="change" class="btn btn-primary btn-block">Reset Your Password</button>
        </div>
      </form>

      
    </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>


  <!-- 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>
    (function(document, window, $) {
      'use strict';

      var Site = window.Site;
      $(document).ready(function() {
        Site.run();
      });
    })(document, window, jQuery);
	
	
	$("input[name='old_password']").keyup(function(){
	
	$.post("ajax/checkpass.php",{apas:$(this).val()},function(data){
		$("#checkoldp").html(data);
		
		if(data=="<strong>Password does not match from records<strong>")
		{
			$("button[type='submit']").attr("disabled",true);
		}
		else
		{
			$("button[type='submit']").attr("disabled",false);
		}
		});
	//
	});
  </script>
  
  <script>
$("input[name='confirm_password']").focusout(function(){

if($("input[name='confirm_password']").val()==$("input[name='password']").val())
{
	$("#matchP").html("<strong>Password Match<strong>");
	$("button[type='submit']").attr("disabled",false);
}
else
{
	$("#matchP").html("<strong>Password Does Not Match<strong>");
	$("button[type='submit']").attr("disabled",true);
	
}


});
</script>

</body>

</html>