-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgedungController.php
37 lines (36 loc) · 974 Bytes
/
gedungController.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
<?php
require_once 'koneksi_db.php';
require_once 'models/gedung.php';
// 1. Tangkap request dari form
$kode = $_POST['kode'];
$nama = $_POST['nama'];
$alt = $_POST['alamat'];
// tombol
$tombol = $_POST['proses'];
// 2. memasukkan ke data array
$data = [
$kode, // ? 1
$nama, // ? 2
$alt // ? 3
];
// 3. Ciptakan object dari class gedung
$obj = new Gedung();
switch ($tombol) {
case 'simpan': $obj->simpan($data);
break;
case 'ubah':
$data[] = $_POST['idx']; // ? ke 4 where id = ?
$obj->ubah($data);
break;
case 'hapus':
unset($data);
$data[] = $_POST['idx']; // ? ke 4 where id ?
$obj->hapus($data);
break;
default:
header('location:index.php?hal=gedung');
break;
}
// 4. Landing page
header('location:index.php?hal=gedung');
?>