-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarang-create.php
71 lines (56 loc) · 1.63 KB
/
barang-create.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
$title = 'Tambah Barang';
require_once "template/theHeader.php";
?>
<div class="level">
<div class="level-left">
<div class="level-item">
<h1 class="title is-4">Tambah Barang</h1>
</div>
</div>
<div class="level-right">
<div class="level-item">
<a href="barang.php" class="button is-light">Kembali</a>
</div>
</div>
</div>
<hr>
<?php
if (isset($_POST['simpan'])) {
$fields = [
'nama_barang' => $_POST['nama'],
'harga_barang' => $_POST['harga'],
'stok_barang' => $_POST['stok'],
];
if (insert('barang', $fields)) {
return header('Location:barang.php');
}
hasMessage('Maaf!, tidak dapat menyimpan data.');
}
?>
<form action="" method="post">
<div class="field">
<label for="nama" class="label">Nama Barang</label>
<div class="control">
<input type="text" name="nama" id="nama" class="input" value="<?= old('nama') ?>" required>
</div>
</div>
<div class="field">
<label for="harga" class="label">Harga</label>
<div class="control">
<input type="number" name="harga" id="harga" class="input" value="<?= old('harga') ?>" required>
</div>
</div>
<div class="field">
<label for="stok" class="label">Stok</label>
<div class="control">
<input type="number" name="stok" id="stok" class="input" value="<?= old('stok') ?>" required>
</div>
</div>
<div class="field">
<button name="simpan" class="button is-success">Simpan</button>
</div>
</form>
<?php
require_once "template/theFooter.php"
?>