<?php include_once('../includes/head.php'); ?>
<?php include_once('includes/admin_auth.php'); ?>
<?php
if(isset($_POST['update-pass'])){
	$pass = $_POST['password'];
	$id= $_POST['user-id'];
	$pass_change=mysql_query("UPDATE `users` SET `password` = '$pass' WHERE `ID` = $id");
	if($pass_change){
		$_SESSION['password']=$pass;
		header("location:change-password.php?success");
	}else{
		header("location:change-password.php?failed");
	}
}
?>
<?php
	$msg='';
	if(isset($_GET['success'])){
		$msg='<div class="alert alert-success" role="alert">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				  <span aria-hidden="true">&times;</span>
				</button>
				The operation completed successfully
			</div>';
	}else if(isset($_GET['failed'])){
		$msg='<div class="alert alert-danger" role="alert">
		<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				  <span aria-hidden="true">&times;</span>
				</button>
		Operation Failed</div>';
	}
?>
	</head>
	<body>
		<?php include_once('../includes/header.php'); ?>
        <div class="container">
			<div class="row">
				<?php include_once('../includes/sidebar.php'); ?>
				<!-- Add new sidebar box here -->
				
				</div><!--Dont remove it-->
				<div class="col-sm-9 admin-content">
					<div class="title col-sm-12">Change Password</div><br>
					<hr/>
					<form method="post" action="change-password.php" method="post">
						<div class="col-sm-12 col-xs-12">
							<?php echo $msg; ?>
							<div class="col-sm-12 col-xs-12 content-boxes">
								<span class="content-box-title"><b>Reset/change your password</b></span>
								<hr>
								<div class="input-fields">
									<span class="col-xs-3">Email / Username :</span>
									<span class="col-xs-9"><input type="email" name="email" value="<?php echo $admin_row['username']; ?>" class="form-control" disabled></span>
								</div>
								
								<div class="input-fields">
									<span class="col-xs-3">New Password:</span>
									<span class="col-xs-9"><input type="password" name="password" class="form-control" required></span>
								</div>
								
							</div>
						</div>
						<div class="col-sm-12 col-xs-12" style="padding-top:20px;">
							<input type="hidden" value="<?php echo $row['ID']; ?>" name="user-id" style="float:right;">
							<input type="submit" value="Update" name="update-pass" style="float:right;">
						</div>
					</form>
				</div>
			</div>
			<hr>
		</div>
		<?php include_once('../includes/footerjs.php'); ?>
	</body>
</html>