<?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'];
    $type = $_POST['type'];
    
    $sql = "insert into electrical (serial_number,name,model,date_start,date_expiry,status,remarks, location, type) values ('$serial_number','$name', '$model', '$date_start','$date_expiry','$status','$remarks', '$location', '$type')";
    if ($conn->query($sql)) {
        $_SESSION['success'] = $name." insert successfully";
    } else {
        $_SESSION['error'] = "Error updating record: " . $conn->error;
    }
    
    header('location: ../electrical_listing.php?type='.$_POST['type']);
?>