<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php

if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");

date_default_timezone_set('Asia/Dhaka');
                    $date_c = date('Y-m-d H:i:s', time());


?>

<!DOCTYPE html>
<html 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">
    <title>Change Password</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
     <link href="assets/css/lib/data-table/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" />
    <link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" />
    <link href="assets/css/lib/weather-icons.css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
	   <link href="assets/css/lib/select2/select2.min.css" rel="stylesheet">
</head>

<body>

    
	
	  <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	
	
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Hello, <span>Welcome Here</span></h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Home</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Change Password</div>
                                            <div class="panel-body">
											
											<?php
	

	
if (isset($_POST['submit'])) {
									  
 
                                     
								    $new_password = $_POST['newPassword'];
									$new_password_again = $_POST['newPasswordAgain'];
								
								if($new_password!=$new_password_again)	{
									echo "<font color='red'><b>Password Not Matched </b></font>";
								}
								
								
									if($new_password==$new_password_again)	{								
//**												  
												  
 $new_password=password_hash($new_password, PASSWORD_BCRYPT);
												  $sqlUpdate = "UPDATE users SET
												  password = '$new_password',
												  updated_at = now()
												  
												  
                                                

                                            WHERE
                                                  id = '$ad_id'           
                     ";  
											 											   
               
                             /* echo $sqlUpdate;
              exit;*/

                                            $sqlUpdated = mysqli_query($connection, $sqlUpdate); 
						$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'changed password', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 					 
 echo "<div>
 </br>
 </div>";
 include_once('updated.html');	
} 
}





$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='sms_api' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
                                    $sms_api = $settingsSQL->value;
								   
											?>
						
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card alert">
                                <div class="card-body">
                                    <div class="form-validation">
								
                                        <form class="form-valide" action="#" method="post">
										   
										
											<div class="form-group row">
                                                <label class="col-lg-2 col-form-label" > New Password   </label>
                                                <div class="col-lg-10">
                                                    <input type="password" class="form-control"  name="newPassword" id="newPassword" placeholder="password">
                                                </div>
                                            </div>
											
											
												<div class="form-group row">
                                                <label class="col-lg-2 col-form-label" > New Password Again  </label>
                                                <div class="col-lg-10">
                                                    <input type="password" class="form-control"  name="newPasswordAgain" id="newPasswordAgain" placeholder="password">
                                                </div>
                                            </div>
											
											
											
											
											
											
                                          
                                            <div class="form-group row">
											 <label class="col-lg-2 col-form-label" for="val-username">    </label>
                                                <div class="col-lg-10 ml-auto">
												    
                                                    <button type="submit" name="submit" class="btn btn-primary">Save</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                                  



                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                   
				   
				   
				           <?php include("footer.php"); ?>
						   
						   
                </section>
            </div>
        </div>
    </div>

    <div id="search">
        <button type="button" class="close">×</button>
        <form>
            <input type="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>


    </div>
    <script src="assets/js/lib/jquery.min.js"></script>
    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <!-- nano scroller -->
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
    <!-- sidebar -->
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- bootstrap -->
   
    <script src="assets/js/scripts.js"></script>
	
	 <script src="assets/js/lib/data-table/datatables.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.dataTables.min.js"></script>
    <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.flash.min.js"></script>
    <script src="assets/js/lib/data-table/jszip.min.js"></script>
    <script src="assets/js/lib/data-table/pdfmake.min.js"></script>
    <script src="assets/js/lib/data-table/vfs_fonts.js"></script>
    <script src="assets/js/lib/data-table/buttons.html5.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.print.min.js"></script>
    <script src="assets/js/lib/data-table/datatables-init.js"></script>
	
	
       <script>
function checkPassword(){
if ($('#newPasswordAgain').val() !== $('#newPassword').val()) {
$('#newPasswordAgain')[0].setCustomValidity('Passwords must match.');
}
else{
$('#newPasswordAgain')[0].setCustomValidity('');
}
}
</script>
   


		 
		 
</body>

</html>