-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditkereta.php
More file actions
33 lines (28 loc) · 874 Bytes
/
editkereta.php
File metadata and controls
33 lines (28 loc) · 874 Bytes
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
<?php
include("config.php");
// cek apakah tombol di form sudah diklik atau belum
if(isset($_POST['tambahkereta'])){
// ambil data dari formulir
$id_kereta = $_POST['id_kereta'];
$nama_kereta = $_POST['nama_kereta'];
$kapasitas = $_POST['kapasitas'];
$operasional = $_POST['operasional'];
if ($operasional === 'Ya'){
$operasional = 'true';
} elseif ($operasional === 'Tidak') {
$operasional = 'false';
}
// buat query
$query = pg_query("UPDATE kereta SET nama = '$nama_kereta', beroperasi = $operasional, kapasitas = $kapasitas WHERE id = $id_kereta");
// apakah query simpan berhasil?
if( $query==TRUE ) {
// kalau berhasil alihkan ke halaman index.php
header('Location: index.php');
} else {
// kalau gagal kembalikan ke halaman form
javascript::history.back();
}
} else {
die("Akses dilarang...");
}
?>