<?php 
ob_start();
session_start();
include 'config/config.php';
include 'config/function.php';
if($_SESSION['member_user_id']=='')
{
    header("Location:Login");
    exit();
}
$member_user_id=$_SESSION['member_user_id'];
$strP="Select password from tbl_memberreg where member_user_id='$member_user_id'";
$password=get_value($strP);
                       
?>
<html lang="en">

<head>
    <title>Change Password : <?php echo get_company(); ?> </title>
   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="Phoenixcoded">
    <!-- Favicon icon -->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">

    <!-- vendor css -->
    <link rel="stylesheet" href="assets/css/style.css">
    
    

</head>
<body class="">
	<!-- [ Pre-loader ] start -->
	<div class="loader-bg">
		<div class="loader-track">
			<div class="loader-fill"></div>
		</div>
	</div>
	<!-- [ Pre-loader ] End -->
	<!-- [ Header ]  -->
<?php include 'inc/vertical.php'; ?>

<!-- [ Main Content ] start -->
<div class="pcoded-main-container">
    <div class="pcoded-content">
        <!-- [ breadcrumb ] start -->
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                           
                            <h6><?php echo $member_user_id=$_SESSION['member_user_id']; ?> (<?php echo $_SESSION['member_name'] ?>)</h6>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>
       <div class="row">
            <div class="col-sm-12">
                <div class="card">
                    <div class="card-header">
                        <h5>Change Password  </h5>
                        <span style="color:red"><?php echo $_REQUEST['msg']; ?></span>
                    </div>
                    <div class="card-body">
                        <form name="frmpassword" id="frmpassword" action="process/ChangePassword" method="post">
                            <div class="row">
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="floating-label" for="Email">Old Password</label>
                                        <input type="password" class="form-control" id="oldPassword"  name="oldPassword" required>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="floating-label" for="Text">New Password</label>
                                        <input type="password" class="form-control" id="newPAssword" name="newPAssword" placeholder="" required>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="floating-label" for="password">Confirm Password</label>
                                        <input type="password" class="form-control" id="cpassword" name="cpassword" placeholder="">
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                 <button type="button" onClick="FormSubmit()" class="btn  btn-primary">Submit</button>
                                  </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
           
        </div>
    </div>
</div>

    <!-- Required Js -->
    <script src="assets/js/vendor-all.min.js"></script>
    <script src="assets/js/plugins/bootstrap.min.js"></script>
    <script src="assets/js/pcoded.min.js"></script>

<!-- Apex Chart -->
<script src="assets/js/plugins/apexcharts.min.js"></script>


<!-- custom-chart js -->
<script src="assets/js/pages/dashboard-main.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
    function FormSubmit()
    {
      var password='<?php echo $password; ?>';
      var oldPassowrd=$.trim($("#oldPassword").val());  
      var newPAssword=$.trim($("#newPAssword").val());  
      var cpassword=$.trim($("#cpassword").val());  
      console.log("Old Password : ",password);
      if(password!=oldPassowrd)
      {
          swal("Wrong Old Password");
          return;
      }
      else if(newPAssword.length<4)
      {
          swal("Password Must have be minimum 4 Charactor  ");
          return;
      }
      else if(newPAssword!=cpassword)
      {
          swal("New Password and Confirm Password Not Same ");
          return;
      }
      else
      {
          $("#frmpassword").submit();
      }
    }
</script>

</body>

</html>
