<?php
    session_start();

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

   
    $username = $_POST['username'];
    $id = $_POST['id'];

    $sql = "UPDATE users SET username='".$username."' where id='".$id."'";

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

?>