<?php
require_once dirname(__DIR__) . '/auth_check.php';
require_once dirname(__DIR__) . '/config.php';

$id          = isset($_POST['id'])          ? (int)$_POST['id'] : 0;
$serviceid   = isset($_POST['serviceid'])   ? mysqli_real_escape_string($koneksi, trim($_POST['serviceid']))   : '';
$servicename = isset($_POST['servicename']) ? mysqli_real_escape_string($koneksi, trim($_POST['servicename'])) : '';
$harga       = isset($_POST['harga'])       ? (float)$_POST['harga'] : 0;

if ($id <= 0 || $serviceid === '' || $servicename === '') { echo "error: Missing fields"; die(); }

$sql = "UPDATE price SET serviceid='$serviceid', servicename='$servicename', harga=$harga WHERE id=$id";
if (mysqli_query($koneksi, $sql)) {
    echo "success";
} else {
    echo "error: " . mysqli_error($koneksi);
}
