<?php
    session_start();

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

    $name = $_POST['name'];
    $size = $_POST['size'];
    $quantity = $_POST['quantity'];
    $id = $_POST['id'];

    // var_dump(var_dump($_POST));
    // die();

    $sql = "UPDATE stocks SET name='".$name."',size='".$size."',quantity='".$quantity."' where id='".$id."'";

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

?>