| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /laragon4/www/bpkd_api/work/ |
Upload File : |
<?php
//action.php
if(isset($_POST["action"]))
{
if($_POST["action"] == 'insert_api')
{
$form_data = array(
'metod' => $_POST['metod'],
'url' => $_POST['url'],
'token' => $_POST['tokenkey'],
'token_yn' => $_POST['token'],
'uraian' => $_POST['uraian'],
'bidang' => $_POST['bidang']
);
$api_url = "http://localhost/bpkd_api/api/test_api.php?action=insert_api"; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_POST, true);
curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
curl_close($client);
$result = json_decode($response, true);
foreach($result as $keys => $values)
{
if($result[$keys]['success'] == '1')
{
echo 'insert';
}
else
{
echo 'error';
}
}
}
if($_POST["action"] == 'fetch_single_api')
{
$id = $_POST["id"];
$api_url = "http://localhost/bpkd_api/api/test_api.php?action=fetch_single_api&id=".$id.""; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
echo $response;
}
if($_POST["action"] == 'update_api')
{
$form_data = array(
'metod' => $_POST['metod'],
'url' => $_POST['url'],
'token' => $_POST['tokenkey'],
'token_yn' => $_POST['token'],
'uraian' => $_POST['uraian'],
'bidang' => $_POST['bidang'],
'id' => $_POST['hidden_id']
);
$api_url = "http://localhost/bpkd_api/api/test_api.php?action=update_api"; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_POST, true);
curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
curl_close($client);
$result = json_decode($response, true);
foreach($result as $keys => $values)
{
if($result[$keys]['success'] == '1')
{
echo 'update';
}
else
{
echo 'error';
}
}
}
if($_POST["action"] == 'delete_api')
{
$id = $_POST['id'];
$api_url = "http://localhost/bpkd_api/api/test_api.php?action=delete_api&id=".$id.""; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
echo $response;
}
}
?>