34116-vm/volunteer.php
2025-09-16 21:02:18 +00:00

173 lines
8.9 KiB
PHP

<?php
require_once __DIR__ . '/mail/MailService.php';
$form_error = '';
$form_success = '';
// Form processing
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Sanitize and validate inputs
$full_name = filter_input(INPUT_POST, 'full_name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$skills = filter_input(INPUT_POST, 'skills', FILTER_SANITIZE_STRING);
$availability = filter_input(INPUT_POST, 'availability', FILTER_SANITIZE_STRING);
$coc = filter_input(INPUT_POST, 'coc', FILTER_SANITIZE_STRING);
if (empty($full_name) || empty($email) || empty($coc)) {
$form_error = 'Please fill out your name, email, and agree to the Code of Conduct.';
} elseif (!$email) {
$form_error = 'Please provide a valid email address.';
} else {
// Prepare email content
$subject = "New Volunteer Sign-up: {$full_name}";
$htmlBody = "
<h1>New Volunteer Sign-up</h1>
<p>A new volunteer has signed up through the website.</p>
<ul>
<li><strong>Full Name:</strong> " . htmlspecialchars($full_name) . "</li>
<li><strong>Email:</strong> " . htmlspecialchars($email) . "</li>
<li><strong>Skills/Interests:</strong><br>" . nl2br(htmlspecialchars($skills)) . "</li>
<li><strong>Availability:</strong><br>" . nl2br(htmlspecialchars($availability)) . "</li>
<li><strong>Agreed to CoC:</strong> Yes</li>
</ul>
<p>Please add them to the volunteer list and follow up with details.</p>
";
$textBody = "
New Volunteer Sign-up
Full Name: {$full_name}
Email: {$email}
Skills/Interests:
{$skills}
Availability:
{$availability}
Agreed to CoC: Yes
";
// Send email
$to = null; // Use MAIL_TO from .env
$options = ['reply_to' => $email];
$result = MailService::sendMail($to, $subject, $htmlBody, $textBody, $options);
if (!empty($result['success'])) {
// Redirect to 'thanks' page on success
header("Location: thanks.php?from=volunteer");
exit;
} else {
// Log error and show a generic message
error_log("MailService Error: " . ($result['error'] ?? 'Unknown error'));
$form_error = 'Sorry, there was an error sending your sign-up. Please try again later or contact us directly.';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Volunteer | Belarusians Worldwide</title>
<meta name="description" content="Join our team as a volunteer for the Belarusian pavilion at Web Summit 2025.">
<meta name="robots" content="noindex, nofollow">
<!-- Fonts -->
<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=IBM+Plex+Sans:wght@400;500&family=Inter:wght@600;700&display=swap" rel="stylesheet">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand fw-bold" href="/">Belarusians Worldwide</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<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="/#why">Why</a></li>
<li class="nav-item"><a class="nav-link" href="sponsor.php">Sponsor</a></li>
<li class="nav-item"><a class="nav-link" href="apply.php">Apply</a></li>
<li class="nav-item"><a class="nav-link active" href="volunteer.php">Volunteer</a></li>
<li class="nav-item"><a class="nav-link" href="media.php">Media</a></li>
</ul>
</div>
</div>
</nav>
</header>
<main class="container my-5">
<div class="row">
<div class="col-lg-8 mx-auto">
<h1 class="mb-4">Volunteer With Us</h1>
<p class="lead mb-5">The pavilion is powered by our community. We need your help with booth shifts, setup, and networking at Night Summit. Sign up below to be a part of the team in Lisbon!</p>
<div class="card">
<div class="card-body">
<h5 class="card-title mb-4">Volunteer Sign-up</h5>
<?php if ($form_error): ?>
<div class="alert alert-danger"><?php echo $form_error; ?></div>
<?php endif; ?>
<div class="alert alert-info small">
<p>This is for testing purposes only — Flatlogic does not guarantee usage of the mail server. Please set up your own SMTP in <code>.env</code> (MAIL_/SMTP_ vars).</p>
<p class="mb-0">If you do not receive a confirmation, please check your spam folder.</p>
</div>
<form action="volunteer.php" method="POST">
<div class="row">
<div class="col-md-6 mb-3">
<label for="full_name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="full_name" name="full_name" required>
</div>
<div class="col-md-6 mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
</div>
<div class="mb-3">
<label for="skills" class="form-label">Skills & Interests</label>
<textarea class="form-control" id="skills" name="skills" rows="3"></textarea>
<div class="form-text">Let us know what you're good at! (e.g., sales, social media, event setup, photography)</div>
</div>
<div class="mb-3">
<label for="availability" class="form-label">Your Availability</label>
<textarea class="form-control" id="availability" name="availability" rows="3"></textarea>
<div class="form-text">When can you help? (e.g., specific days at Web Summit, pre-event tasks)</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="coc" name="coc" value="1" required>
<label class="form-check-label" for="coc">I agree to the <a href="code-of-conduct.php" target="_blank">Code of Conduct</a>.</label>
</div>
<button type="submit" class="btn btn-primary w-100">Sign Up to Volunteer</button>
</form>
</div>
</div>
</div>
</div>
</main>
<footer class="footer mt-5">
<div class="container text-center">
<p class="mb-1">&copy; <?php echo date("Y"); ?> Belarusians Worldwide. A self-funded, non-state initiative.</p>
<ul class="list-inline">
<li class="list-inline-item"><a href="privacy.php">Privacy</a></li>
<li class="list-inline-item"><a href="code-of-conduct.php">Code of Conduct</a></li>
<li class="list-inline-item"><a href="media.php">Press</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<!-- Custom JS -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>