<?php
    session_start();

    require("../includes/database_connect.php");

    $password = $_POST['password'];
    $confirm_password = $_POST['confirm_password'];
    $id = $_POST['id'];

    if($password == $confirm_password) {
        $sql = "update users  set password='".$password."' where id='".$id."'";
        if ($conn->query($sql)) {
            $_SESSION['success'] = "Password updated successfully";
        } else {
            $_SESSION['error'] = "Error updating record: " . $conn->error;
        }
    }
    
    header('location: ../user_edit.php?id='.$id);

?>