<?php
    session_start();

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

    $serial_number = $_POST['serial_number'];
    $name = $_POST['name'];
    $model = $_POST['model'];
    $date_start = $_POST['date_start'];
    $date_expiry = $_POST['date_expiry'];
    $status = $_POST['status'];
    $remarks = $_POST['remarks'];
    $location = $_POST['location'];
    $id = $_POST['id'];
    $type = $_POST['type'];

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

    $sql = "UPDATE electrical SET serial_number='".$serial_number."',name='".$name."',model='".$model."',date_start='".$date_start."', date_expiry='".$date_expiry."', status='".$status."', remarks='".$remarks."', location='".$location."'  where id='".$id."'";

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

?>