<?php
include("../includes/auth.php");
include("../config/db.php");

$id = $_GET['id'];

if (isset($_POST['update'])) {
    $password = password_hash($_POST['password'], PASSWORD_DEFAULT);

    $conn->query("UPDATE users SET password='$password' WHERE id=$id");

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

<?php include("../includes/header.php"); ?>
<?php include("../includes/sidebar.php"); ?>

<h3>Change Password</h3>

<form method="POST">
    <input type="password" name="password" class="form-control mb-2" placeholder="New Password">
    <button name="update" class="btn btn-success">Update Password</button>
</form>

<?php include("../includes/footer.php"); ?>