<?php
if ($c['level'] == "superadmin") {

    if (isset($_POST['upload'])) {

        $id = $_POST['id'];
        $agent_code = $_POST['agent_code'];
        $agent_token = $_POST['agent_token'];
        $endpoint= $_POST['endpoint'];

        $query = mysqli_query($koneksi, "
            UPDATE tb_api SET
                agent_code = '$agent_code',
                agent_token = '$agent_token',
                endpoint = '$endpoint'
                
            WHERE id = '$id'
        ");

        if ($query) {
            echo "<script>alert('Data API berhasil diubah');window.location='?page=api';</script>";
        } else {
            echo "<script>alert('Data API gagal diubah');window.location='?page=api';</script>";
        }
    }

} else {
    echo "<script>window.location='?page=dashboard';</script>";
}
?>