Skip to content

Instantly share code, notes, and snippets.

@misskecupbung
Created May 18, 2023 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misskecupbung/f61ea629ecf55371fd70c1318339a97b to your computer and use it in GitHub Desktop.
Save misskecupbung/f61ea629ecf55371fd70c1318339a97b to your computer and use it in GitHub Desktop.
<?php
require_once "method.php";
$mhs = new Mahasiswa();
$request_method=$_SERVER["REQUEST_METHOD"];
switch ($request_method) {
case 'GET':
if(!empty($_GET["id"]))
{
$id=intval($_GET["id"]);
$mhs->get_mhs($id);
}
else
{
$mhs->get_mhss();
}
break;
case 'POST':
if(!empty($_GET["id"]))
{
$id=intval($_GET["id"]);
$mhs->update_mhs($id);
}
else
{
$mhs->insert_mhs();
}
break;
case 'DELETE':
$id=intval($_GET["id"]);
$mhs->delete_mhs($id);
break;
default:
// Invalid Request Method
header("HTTP/1.0 405 Method Not Allowed");
break;
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment