-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
47 lines (43 loc) · 1.17 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$base = "/project/fundamental-oop/";
// project base
// incoming URL
$request = $_SERVER['REQUEST_URI'];
$method = $_SERVER['REQUEST_METHOD'];
//param
$id = isset($_GET['id']) ? $_GET['id'] : '';
// cek url dan tipe request
// str_replace , untuk jika ada space
switch (str_replace('%20', ' ', $request)) {
case $base:
require "app/home.php";
break;
case $base.'produk' :
require "app/produk.php";
break;
case $base.'produk?id='.$id:
require "app/detailProduk.php";
break;
case $base.'produk/hapus?id='.$id:
require "app/hapusProduk.php";
break;
case $base.'produk/tambah':
require "app/tambahProduk.php";
break;
case $base.'produk/simpan':
require "app/simpanProduk.php";
break;
case $base.'produk/edit?id='.$id:
require "app/editProduk.php";
break;
case $base.'produk/update':
require "app/updateProduk.php";
break;
case ($request==$base.'produk/filter' && $method=='POST'):
require "app/filterProduk.php";
break;
default:
http_response_code(404);
echo "404 - NOT FOUND";
break;
}