94 lines
3.9 KiB
PHP
94 lines
3.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>E-Waste Reclaimer</title>
|
|
<meta name="description" content="A platform to help you recycle your e-waste responsibly.">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="container">
|
|
<div class="logo">
|
|
<h1><a href="index.php">E-Waste Reclaimer</a></h1>
|
|
</div>
|
|
<nav>
|
|
<ul>
|
|
<li><a href="index.php">Find a Center</a></li>
|
|
<?php if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true): ?>
|
|
<li><a href="dashboard.php">Dashboard</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 page-main">
|
|
<section class="hero">
|
|
<h2>Welcome to E-Waste Reclaimer</h2>
|
|
<p>Your partner in responsible electronics recycling. Find a center near you and help us build a sustainable future.</p>
|
|
<a href="#centers-list" class="btn btn-primary">Find a Center</a>
|
|
</section>
|
|
|
|
<section id="centers-list" class="centers-section">
|
|
<h2>Recycling Centers</h2>
|
|
<div class="card-container">
|
|
<?php
|
|
try {
|
|
$pdo = db();
|
|
|
|
$stmt = $pdo->query("SELECT COUNT(*) FROM centers");
|
|
if ($stmt->fetchColumn() == 0) {
|
|
$sample_centers = [
|
|
['name' => 'GreenTech Recyclers', 'address' => '123 Eco Lane, Green City', 'contact' => 'contact@greentech.com'],
|
|
['name' => 'Circuit Savers', 'address' => '456 Recycle Ave, Tech Town', 'contact' => 'info@circuitsavers.com'],
|
|
['name' => 'Eco-Warriors', 'address' => '789 Planet Blvd, Nature Village', 'contact' => 'support@ecowarriors.org']
|
|
];
|
|
|
|
$insert_stmt = $pdo->prepare("INSERT INTO centers (name, address, contact) VALUES (:name, :address, :contact)");
|
|
foreach ($sample_centers as $center) {
|
|
$insert_stmt->execute($center);
|
|
}
|
|
}
|
|
|
|
$centers = $pdo->query("SELECT * FROM centers ORDER BY name")->fetchAll();
|
|
|
|
} catch (PDOException $e) {
|
|
$centers = [];
|
|
error_log("Database error: " . $e->getMessage());
|
|
}
|
|
|
|
if (!empty($centers)):
|
|
foreach ($centers as $center): ?>
|
|
<div class="card">
|
|
<div class="card-icon"><i class="fas fa-recycle"></i></div>
|
|
<h3><?php echo htmlspecialchars($center['name']); ?></h3>
|
|
<p><i class="fas fa-map-marker-alt"></i> <?php echo htmlspecialchars($center['address']); ?></p>
|
|
<p><i class="fas fa-envelope"></i> <?php echo htmlspecialchars($center['contact']); ?></p>
|
|
</div>
|
|
<?php endforeach;
|
|
else: ?>
|
|
<div class="alert alert-info">No recycling centers found. Please check back later.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<footer>
|
|
<div class="container">
|
|
<p>© <?php echo date("Y"); ?> E-Waste Reclaimer. All Rights Reserved.</p>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|