| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/bpkd/admin/ |
Upload File : |
<?php
$page_title = 'Pesan Kontak';
require_once 'config/database.php';
require_once '../includes/config.php';
require_once 'includes/header.php';
// Handle delete
if (isset($_GET['delete'])) {
$id = (int)$_GET['delete'];
$conn->query("DELETE FROM contacts WHERE id = $id");
redirect(BASE_URL . '/admin/contacts.php?msg=deleted');
}
// Get contacts
$contacts_query = "SELECT * FROM contacts ORDER BY created_at DESC";
$contacts = $conn->query($contacts_query);
if (!$contacts) {
die("Error in contacts query: " . $conn->error);
}
$msg = '';
if (isset($_GET['msg']) && $_GET['msg'] == 'deleted') {
$msg = '<div class="alert alert-success">Pesan berhasil dihapus!</div>';
}
?>
<div class="container-fluid">
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Pesan Kontak Masuk</h1>
</div>
<?php echo $msg; ?>
<!-- Contacts List -->
<div class="card shadow mb-4">
<div class="card-body">
<?php if ($contacts && $contacts->num_rows > 0): ?>
<?php while($contact = $contacts->fetch_assoc()): ?>
<div class="contact-item mb-4 p-3 border rounded">
<div class="row">
<div class="col-md-9">
<div class="d-flex">
<div class="me-3">
<div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center" style="width: 50px; height: 50px;">
<i class="fas fa-user fa-lg"></i>
</div>
</div>
<div class="flex-grow-1">
<h5 class="mb-1">
<?php echo htmlspecialchars($contact['name']); ?>
</h5>
<p class="mb-2">
<i class="fas fa-envelope text-muted me-1"></i>
<a href="mailto:<?php echo htmlspecialchars($contact['email']); ?>">
<?php echo htmlspecialchars($contact['email']); ?>
</a>
<?php if(!empty($contact['phone'])): ?>
<br><i class="fas fa-phone text-muted me-1"></i>
<a href="tel:<?php echo htmlspecialchars($contact['phone']); ?>">
<?php echo htmlspecialchars($contact['phone']); ?>
</a>
<?php endif; ?>
</p>
<?php if(!empty($contact['subject'])): ?>
<h6 class="text-primary"><?php echo htmlspecialchars($contact['subject']); ?></h6>
<?php endif; ?>
<div class="message-content p-3 bg-light rounded">
<?php echo nl2br(htmlspecialchars($contact['message'])); ?>
</div>
<p class="text-muted small mt-2">
<i class="fas fa-clock me-1"></i><?php echo date('d M Y H:i', strtotime($contact['created_at'])); ?>
<?php if(!empty($contact['ip_address'])): ?>
| <i class="fas fa-network-wired me-1"></i>IP: <?php echo $contact['ip_address']; ?>
<?php endif; ?>
</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="d-flex flex-column align-items-end">
<a href="mailto:<?php echo $contact['email']; ?>?subject=Re: <?php echo urlencode($contact['subject']); ?>"
class="btn btn-sm btn-success mb-2 w-100" target="_blank">
<i class="fas fa-reply me-1"></i> Balas Email
</a>
<a href="<?php echo BASE_URL; ?>/admin/contacts.php?delete=<?php echo $contact['id']; ?>"
class="btn btn-sm btn-danger w-100"
onclick="return confirm('Yakin ingin menghapus pesan ini?')">
<i class="fas fa-trash me-1"></i> Hapus
</a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-inbox fa-4x text-muted mb-3"></i>
<h5>Tidak ada pesan</h5>
<p class="text-muted">Belum ada pesan dari form kontak</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<style>
.contact-item {
transition: all 0.3s ease;
}
.contact-item:hover {
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.message-content {
max-height: 200px;
overflow-y: auto;
}
</style>
<?php require_once 'includes/footer.php'; ?>