<?php 
include 'conn.php';
if($_GET['function']=="INT"){
    $fields = $_POST['fields'];
    $values = $_POST['data'];
    $tags = implode(', ',  $fields);
    $result = "`" . implode ( "`, `", $fields ) . "`";
    $values = "'" . implode ( "', '", $values ) . "'"; 
    $desc="";
    $INSERT = "INSERT INTO `interior_report`($result)  VALUES ($values)";
    $descRes = $mysqli->query($INSERT);
    if($descRes){
        die(json_encode("Data has been saved"));
    }else{
        // Delete All Other with same Value
       die();
    }


   

}else if($_GET['function']=="EXT"){
    $fields = $_POST['fields'];
    $values = $_POST['data'];
    $tags = implode(', ',  $fields);
    $result = "`" . implode ( "`, `", $fields ) . "`";
    $values = "'" . implode ( "', '", $values ) . "'"; 
    $desc="";
    $INSERT = "INSERT INTO `exterior_report`($result)  VALUES ($values)";
    $descRes = $mysqli->query($INSERT);
    if($descRes){
        die(json_encode("Data has been saved"));
    }else{
        // Delete All Other with same Value
       die();
    }


}else if($_GET['function']=="ENG"){
    $fields = $_POST['fields'];
    $values = $_POST['data'];
    $tags = implode(', ',  $fields);
    $result = "`" . implode ( "`, `", $fields ) . "`";
    $values = "'" . implode ( "', '", $values ) . "'"; 
    $desc="";
    $INSERT = "INSERT INTO `engine_room_report`($result)  VALUES ($values)";
    $descRes = $mysqli->query($INSERT);
    if($descRes){
        die(json_encode("Data has been saved"));
    }else{
        // Delete All Other with same Value
       die();
    }

    
}else if($_GET['function']=="CMT"){
    // $fields = $_POST['fields'];
    // $values = $_POST['data'];
    // $tags = implode(', ',  $fields);
    // $result = "`" . implode ( "`, `", $fields ) . "`";
    // $values = "'" . implode ( "', '", $values ) . "'"; 
    // $desc="";
    // $INSERT = "INSERT INTO `interior_report`($result)  VALUES ($values)";
    // $descRes = $mysqli->query($INSERT);
    // if($descRes){
        
    // }else{
    //     // Delete All Other with same Value
    //    die();
    // }

    
}
// $data = [];
// $userID = $_POST['user'];
// $password = $_POST['password'];
// $role = $_POST['role']; 
// $hashed = hash('sha512', $password);
// $desc = "INSERT INTO `users`(`userID`, `password`, `plain`, `role`, `status`)
//  VALUES ('$userID','$hashed','$password','$role','1')";
// $descRes = $mysqli->query($desc);
// if($descRes){
//     $response['status'] = true;
//     $response['response'] = "User Created Successfully";  
//     die(json_encode($response));
// }else{
//     $response['status'] = false;
//     $response['response'] = $mysqli -> error;  
//     die(json_encode($response));
// }
 
 


?>