<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if (isset($_POST['refid'], $_POST['name'])) {
    $refid = $_POST['refid'];
    $name = $_POST['name'];
    $preferred = 'N';

    $stmt = $conn->prepare("INSERT INTO analysisvocabulary (nameanalysisvoc, refid, preferred) VALUES (?, ?, ?)");
    $stmt->bind_param('sis', $name, $refid, $preferred);

    if ($stmt->execute()) {
        echo json_encode(['success' => true]);
    } else {
        echo json_encode(['success' => false, 'error' => $stmt->error]);
    }
} else {
    echo json_encode(['success' => false, 'error' => 'Invalid input']);
}
