<?php include("sass/icon_for_datepicker_and_datatable.php");?>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <?php include("sass/sidebar.php");?>
<?php



if(isset($_POST['submit']))
    {
$password = md5($_POST['pass1']);
 $old_pass = md5($_POST['old_pass']);
 
 if (empty($password)) {
 $message= "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' 
      aria-hidden='true'>
      &times;
   </button>
  Please Insert Password.
</div>";
 
 }
 
 else {
 
 $check=mysqli_query($connection,"select * from users WHERE users_id = '$user_id_for_header_user' and password ='$old_pass'");
$checkrows=mysqli_num_rows($check);
if($checkrows<1){$message= "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' 
      aria-hidden='true'>
      &times;
   </button>
   Sorry, Did Not match the present password.
</div>";}

else{ 


mysqli_query($connection,"UPDATE users SET password ='$password' WHERE users_id = '$user_id_for_header_user' and password ='$old_pass'")
				or die(mysqli_error()); 


$message= "<div class='alert alert-success  alert-dismissable'><button type='button' class='close' data-dismiss='alert' 
      aria-hidden='true'>
      &times;
   </button>
   Your Password Successfully Changed.
</div>";

}




}
}
?>
            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        Change Password
                        <small>Control panel</small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li class="active"> Change Password</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
					<div class="col-md-8">
                    
                    <form class="form-horizontal" role="form" action="<?php echo "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" method="post" enctype="multipart/form-data">
                <div class="body">
					<?php
						if (!empty($message))
						echo "<font color='#FF0000'><h4>$message</h4></font>";
                    ?>
                    <div class="form-group">
                        <input type="password" class="form-control"  name="old_pass" placeholder="Present Password" required>
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control"  name="pass1" id="pass1" placeholder="New Password" required>
                    </div>
                    <div class="form-group">
                    <span id="confirmMessage" class="confirmMessage"></span>
                        <input type="password" class="form-control"  name="pass2" id="pass2" placeholder="Retype Password" onKeyUp="checkPass(); return false;" required>
                    </div>
                    
                </div>
                <div class="footer pull-right">                    
					<button type="reset" class="btn btn-warning btn-lg"><i class="fa fa-refresh"></i> &nbsp; Reset</button>
                    <button type="submit" name="submit" class="btn bg-olive btn-lg"><i class="fa fa-save"></i> &nbsp; Save</button>
                </div>
            </form>
                    
                    </div>
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
<!--Password Match Script Start--->
<script type="text/javascript">
function checkPass()
{
    //Store the password field objects into variables ...
    var pass1 = document.getElementById('pass1');
    var pass2 = document.getElementById('pass2');
    //Store the Confimation Message Object ...
    var message = document.getElementById('confirmMessage');
    //Set the colors we will be using ...
    var goodColor = "#66cc66";
    var badColor = "#ff6666";
    //Compare the values in the password field 
    //and the confirmation field
    if(pass1.value == pass2.value){
        //The passwords match. 
        //Set the color to the good color and inform
        //the user that they have entered the correct password 
        pass2.style.backgroundColor = goodColor;
        message.style.color = goodColor;
        message.innerHTML = "Passwords Match!"
    }else{
        //The passwords do not match.
        //Set the color to the bad color and
        //notify the user.
        pass2.style.backgroundColor = badColor;
        message.style.color = badColor;
        message.innerHTML = "Passwords Do Not Match!"
    }
}  
</script>
<!--Password Match Script End--->
  <?php include("sass/footer_for_datepicker_and_datatable.php");?>
    </body>
</html>