116 lines
5.7 KiB
PHP
116 lines
5.7 KiB
PHP
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
require_once 'db/config.php';
|
|
|
|
$name = trim($_POST['name'] ?? '');
|
|
$email = trim($_POST['email'] ?? '');
|
|
|
|
if (!empty($name) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
try {
|
|
$pdo = db();
|
|
$sql = "INSERT INTO volunteers (name, email) VALUES (:name, :email)";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
|
|
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
|
|
if ($stmt->execute()) {
|
|
header('Location: volunteer_signup.php?status=success');
|
|
} else {
|
|
header('Location: volunteer_signup.php?status=error');
|
|
}
|
|
} catch (PDOException $e) {
|
|
if ($e->errorInfo[1] == 1062) { // Duplicate entry
|
|
header('Location: volunteer_signup.php?status=duplicate');
|
|
} else {
|
|
header('Location: volunteer_signup.php?status=error');
|
|
}
|
|
}
|
|
} else {
|
|
header('Location: volunteer_signup.php?status=invalid');
|
|
}
|
|
exit();
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Volunteer Signup - Food Rescue</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; }
|
|
.navbar { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
|
|
.card { border-radius: 0.5rem; border: none; box-shadow: 0 4px 8px rgba(0,0,0,.1); }
|
|
.form-label { font-weight: 600; }
|
|
.btn-primary { background-color: #0d6efd; border-color: #0d6efd; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php" style="font-weight: 600;">Food Rescue</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"><span class="navbar-toggler-icon"></span></button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="add_listing.php">Add Listing</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="ngo_dashboard.php">NGO Dashboard</a></li>
|
|
<li class="nav-item"><a class="nav-link active" href="volunteer_signup.php">Volunteer Signup</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="volunteer_dashboard.php">Volunteer Dashboard</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="volunteer_hub_old.php">Find Pickups</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="distribution_map.php">Distribution Map</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="admin_panel.php">Admin Panel</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container my-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-6">
|
|
<div class="card p-4">
|
|
<div class="card-body">
|
|
<h2 class="card-title text-center mb-4">Join as a Volunteer</h2>
|
|
<?php if (isset($_GET['status'])): ?>
|
|
<div class="alert alert-<?php echo $_GET['status'] === 'success' ? 'success' : 'danger'; ?>" role="alert">
|
|
<?php
|
|
switch ($_GET['status']) {
|
|
case 'success':
|
|
echo 'Thank you for signing up!';
|
|
break;
|
|
case 'duplicate':
|
|
echo 'This email is already registered.';
|
|
break;
|
|
default:
|
|
echo 'Something went wrong. Please try again.';
|
|
break;
|
|
}
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<form action="volunteer_signup.php" method="POST">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Full Name</label>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email Address</label>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary">Sign Up</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|