Spaces:
Configuration error

brucelloyd1's picture
You are a professional full-stack web developer assistant.
8df07b6 verified
Raw History Blame Contribute Delete
5.4 kB
```php
<?php
include 'includes/auth.php';
include 'config/database.php';
$db = new Database();
$connection = $db->getConnection();
// Get recent items
$query = "SELECT i.*, r.locationFound FROM items i
LEFT JOIN reports r ON i.reportID = r.reportID
WHERE i.status IN ('available', 'stored')
ORDER BY i.createdAt DESC LIMIT 6";
$stmt = $connection->prepare($query);
$stmt->execute();
$recentItems = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get stats
$stats = [];
$queries = [
'total_items' => "SELECT COUNT(*) as count FROM items",
'verified_items' => "SELECT COUNT(*) as count FROM items WHERE status = 'available'",
'pending_claims' => "SELECT COUNT(*) as count FROM claims WHERE status = 'pending'",
'total_users' => "SELECT COUNT(*) as count FROM users"
];
foreach ($queries as $key => $query) {
$stmt = $connection->prepare($query);
$stmt->execute();
$stats[$key] = $stmt->fetch(PDO::FETCH_ASSOC)['count'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lost & Found Management System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="container">
<nav>
<div class="logo">Lost & Found Pro</div>
<ul class="nav-links">
<li><a href="home.php">Home</a></li>
<li><a href="items.php">Browse Items</a></li>
<?php if (isLoggedIn()): ?>
<li><a href="dashboard.php">Dashboard</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="logout.php">Logout</a></li>
<?php else: ?>
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
<?php endif; ?>
</ul>
</nav>
</div>
</header>
<main class="container">
<section class="hero">
<h1>Welcome to Lost & Found Pro</h1>
<p>Reuniting lost items with their owners since 2024</p>
<div class="mt-4">
<form action="items.php" method="GET" class="d-flex justify-between align-center" style="max-width: 500px; margin: 0 auto;">
<input type="text" name="search" class="form-control" placeholder="Search for lost items..." style="margin-right: 10px;">
<button type="submit" class="btn btn-primary">Search</button>
</form>
</div>
</section>
<div class="row">
<div class="col-3">
<div class="card text-center">
<h3><?php echo $stats['total_items']; ?></h3>
<p>Total Items</p>
</div>
</div>
<div class="col-3">
<div class="card text-center">
<h3><?php echo $stats['verified_items']; ?></h3>
<p>Available Items</p>
</div>
</div>
<div class="col-3">
<div class="card text-center">
<h3><?php echo $stats['pending_claims']; ?></h3>
<p>Pending Claims</p>
</div>
</div>
<div class="col-3">
<div class="card text-center">
<h3><?php echo $stats['total_users']; ?></h3>
<p>Registered Users</p>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h2>Recently Found Items</h2>
</div>
<div class="row">
<?php foreach ($recentItems as $item): ?>
<div class="col-4">
<div class="card">
<?php if ($item['imagePath']): ?>
<img src="<?php echo $item['imagePath']; ?>" alt="<?php echo $item['description']; ?>" style="width: 100%; height: 200px; object-fit: cover; border-radius: 5px;">
<?php else: ?>
<div style="width: 100%; height: 200px; background: #e9ecef; display: flex; align-items: center; justify-content: center; border-radius: 5px;">
<span>No Image</span>
</div>
<?php endif; ?>
<h4 class="mt-2"><?php echo $item['category']; ?></h4>
<p><?php echo substr($item['description'], 0, 100); ?>...</p>
<p><small>Found at: <?php echo $item['locationFound']; ?></small></p>
<a href="items.php?item=<?php echo $item['itemID']; ?>" class="btn btn-primary btn-sm mt-1">View Details</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</main>
<footer>
<div class="container">
<div class="footer-content">
<div class="logo">Lost & Found Pro</div>
<p>&copy; 2024 Lost & Found Management System. All rights reserved.</p>
</div>
</div>
</footer>
</body>
</html>
```