<?php include('session.php')?>
<?php include('header.php')?>
<link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
<style>
img.banner {
width: 145px;
height: 86px;
}
</style>
<?php
include ("connect.php");
$user = $_SESSION['username'];
if(isset($_POST['re_password']))
{
$old_pass=md5($_POST['old_pass']);
$new_pass=md5($_POST['new_pass']);
$re_pass=md5($_POST['re_pass']);
$chg_pwd=mysqli_query($conn, "SELECT * FROM user WHERE username='".$user."'");
$chg_pwd1=mysqli_fetch_array($chg_pwd);
$data_pwd=$chg_pwd1['password'];
if($data_pwd==$old_pass){
if($new_pass==$re_pass){
$update_pwd=mysqli_query($conn, "UPDATE user SET password='$new_pass' WHERE username='".$user."'");
echo "<script>alert('Password Changed'); window.location='logout.php'</script>";
}
else{
echo "<script>alert('Your new and Retype Password is not match'); window.location='change.php'</script>";
}
}
else
{
echo "<script>alert('Your old password is wrong'); window.location='change.php'</script>";
}}
?>
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<?php include('sidebar.php')?>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<?php include('topbar.php')?>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Change Password</h1>
</div>
<div class="card shadow mb-4">
<div class="col-lg-7">
<div class="p-5">
<div class="text-center">
</div>
<form class="user" method="post" enctype="multipart/form-data">
<div class="form-group row">
<div class="col-sm-12 mb-3 mb-sm-0">
<label for="exampleInputFile">Old Password</label>
<input type="password" class="form-control" id="password1" placeholder="Old Password" required name="old_pass">
</div>
</div>
<div class="form-group row">
<div class="col-sm-12 mb-3 mb-sm-0">
<label for="exampleInputFile">New Password</label>
<input type="password" class="form-control" id="password1" placeholder="New Password" required name="new_pass">
</div>
</div>
<div class="form-group row">
<div class="col-sm-12 mb-3 mb-sm-0">
<label for="exampleInputFile">Repeat New Password</label>
<input type="password" class="form-control" id="password2" placeholder="Repeat New Password" required name="re_pass">
</div>
</div>
<input type="submit" class="btn btn-primary btn-user btn-block" name="re_password" data-loading-text="Changing Password..." value="Change Password">
</form>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<?php include('footer.php')?>