-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_kamar.php
More file actions
89 lines (76 loc) · 3.57 KB
/
Copy pathedit_kamar.php
File metadata and controls
89 lines (76 loc) · 3.57 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
include "config/koneksi.php"; // koneksi ke database
// Ambil ID kamar dari URL
if (isset($_GET['id'])) {
$id_room = intval($_GET['id']);
// Ambil data kamar dari database
$query = $conn->prepare("SELECT * FROM tb_rooms WHERE id_room = ?");
$query->bind_param("i", $id_room);
$query->execute();
$result = $query->get_result();
if ($result->num_rows === 1) {
$room = $result->fetch_assoc();
} else {
echo "<script>alert('Kamar tidak ditemukan.'); window.location='rooms.php';</script>";
exit;
}
} else {
echo "<script>alert('ID kamar tidak valid.'); window.location='rooms.php';</script>";
exit;
}
?>
<?php include "header.php"; ?>
<?php include "sidebar.php"; ?>
<main class="main-content">
<?php include "topnav.php"; ?>
<div class="card-eljie">
<div class="card-header-eljie">
<div>
<h2>Edit Data Kamar</h2>
<p>Silakan ubah data kamar di bawah ini</p>
</div>
</div>
<div class="card-body-eljie">
<form action="proses_edit_kamar.php" method="POST" enctype="multipart/form-data" class="form">
<input type="hidden" name="id_room" value="<?= htmlspecialchars($room['id_room']); ?>">
<div class="form-group">
<label for="room_type">Nama Kamar</label>
<input type="text" name="room_type" id="room_type" class="form-control" value="<?= htmlspecialchars($room['room_type']); ?>" required>
</div>
<div class="form-group">
<label for="price">Harga</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Rp</span>
</div>
<input type="text" name="price" id="price" class="form-control" value="<?= number_format($room['price'], 2, ',', '.'); ?>" required>
</div>
</div>
<div class="form-group">
<label for="status">Status</label>
<select name="status" id="status" class="form-control" required>
<option value="tersedia" <?= ($room['status'] == 'tersedia') ? 'selected' : ''; ?>>Tersedia</option>
<option value="terisi" <?= ($room['status'] == 'terisi') ? 'selected' : ''; ?>>Terisi</option>
<option value="maintenance" <?= ($room['status'] == 'maintenance') ? 'selected' : ''; ?>>Maintenance</option>
</select>
</div>
<div class="form-group">
<label for="foto">Foto</label>
<input type="file" name="foto" id="foto" class="form-control" accept="image/*">
<?php if ($room['foto']): ?>
<img id="preview-foto" src="uploads/<?php echo $room['foto']; ?>" alt="Preview Foto" style="display: block; margin-top: 10px; max-height: 150px; border-radius: 6px;">
<?php endif; ?>
</div>
<div class="form-actions">
<a href="rooms.php" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Batal
</a>
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Update
</button>
</div>
</form>
</div>
</div>
</main>
<script src="./assets/js/dashboard.js"></script>