CoolFace
Apppublic

starinfolab/codecraft-conductor-wizard

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
dashboard.php103 linesDownload Raw Back to admin
1```php2<?php3session_start();4if (!isset($_SESSION['admin_logged_in'])) {5    header('Location: login.php');6    exit;7}8 9// Database connection10$db = new mysqli('localhost', 'root', '', 'portfolio_db');11if ($db->connect_error) {12    die("Connection failed: " . $db->connect_error);13}14 15// Get contact form submissions16$contacts_query = "SELECT * FROM contact_submissions ORDER BY created_at DESC";17$contacts_result = $db->query($contacts_query);18?>19 20<!DOCTYPE html>21<html lang="en">22<head>23    <meta charset="UTF-8">24    <meta name="viewport" content="width=device-width, initial-scale=1.0">25    <title>Admin Dashboard</title>26    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">27    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>28</head>29<body class="bg-gray-100">30    <div class="flex h-screen">31        <!-- Sidebar -->32        <div class="bg-gray-800 text-white w-64 min-h-screen p-4">33            <div class="flex items-center space-x-2 mb-8 p-2">34                <i data-feather="shield"></i>35                <span class="font-bold text-lg">Admin Panel</span>36            </div>37            <nav>38                <a href="dashboard.php" class="flex items-center space-x-2 p-2 bg-gray-700 rounded mb-2">39                    <i data-feather="home" class="w-5 h-5"></i>40                    <span>Dashboard</span>41                </a>42                <a href="messages.php" class="flex items-center space-x-2 p-2 hover:bg-gray-700 rounded mb-2">43                    <i data-feather="mail" class="w-5 h-5"></i>44                    <span>Messages</span>45                </a>46                <a href="logout.php" class="flex items-center space-x-2 p-2 hover:bg-gray-700 rounded">47                    <i data-feather="log-out" class="w-5 h-5"></i>48                    <span>Logout</span>49                </a>50            </nav>51        </div>52 53        <!-- Main Content -->54        <div class="flex-1 p-8">55            <h1 class="text-2xl font-bold text-gray-800 mb-6">Dashboard</h1>56            57            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">58                <div class="bg-white p-6 rounded-lg shadow">59                    <div class="flex justify-between items-center">60                        <div>61                            <h3 class="text-gray-500">Total Messages</h3>62                            <p class="text-2xl font-bold"><?php echo $contacts_result->num_rows; ?></p>63                        </div>64                        <div class="bg-teal-100 p-3 rounded-full">65                            <i data-feather="mail" class="text-teal-600"></i>66                        </div>67                    </div>68                </div>69            </div>70 71            <div class="bg-white rounded-lg shadow overflow-hidden">72                <div class="px-6 py-4 border-b border-gray-200">73                    <h2 class="text-lg font-semibold text-gray-800">Recent Messages</h2>74                </div>75                <div class="overflow-x-auto">76                    <table class="min-w-full divide-y divide-gray-200">77                        <thead class="bg-gray-50">78                            <tr>79                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>80                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>81                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Message</th>82                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>83                            </tr>84                        </thead>85                        <tbody class="bg-white divide-y divide-gray-200">86                            <?php while ($contact = $contacts_result->fetch_assoc()): ?>87                            <tr>88                                <td class="px-6 py-4 whitespace-nowrap"><?php echo htmlspecialchars($contact['name']); ?></td>89                                <td class="px-6 py-4 whitespace-nowrap"><?php echo htmlspecialchars($contact['email']); ?></td>90                                <td class="px-6 py-4"><?php echo substr(htmlspecialchars($contact['message']), 0, 50) . '...'; ?></td>91                                <td class="px-6 py-4 whitespace-nowrap"><?php echo date('M d, Y', strtotime($contact['created_at'])); ?></td>92                            </tr>93                            <?php endwhile; ?>94                        </tbody>95                    </table>96                </div>97            </div>98        </div>99    </div>100    <script>feather.replace();</script>101</body>102</html>103```