You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
272 lines
6.9 KiB
272 lines
6.9 KiB
6 months ago
|
<?php
|
||
|
// Initialize variables for form data (if form is submitted)
|
||
|
$name = $age = $blood_group = $contact = $email = $address = "";
|
||
|
|
||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||
|
$name = $_POST['name'];
|
||
|
$age = $_POST['age'];
|
||
|
$blood_group = $_POST['blood-group'];
|
||
|
$contact = $_POST['contact'];
|
||
|
$email = $_POST['email'];
|
||
|
$address = $_POST['address'];
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8" />
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
|
<title>Blood Donation - Save Lives</title>
|
||
|
<style>
|
||
|
/* General Styles */
|
||
|
body {
|
||
|
margin: 0;
|
||
|
font-family: Arial, sans-serif;
|
||
|
background-color: #f9f9f9;
|
||
|
color: #333;
|
||
|
}
|
||
|
|
||
|
header {
|
||
|
background-color: #d32f2f;
|
||
|
color: white;
|
||
|
padding: 10px 20px;
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
align-items: center;
|
||
|
}
|
||
|
|
||
|
header .logo {
|
||
|
font-size: 24px;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
|
||
|
header nav ul {
|
||
|
list-style: none;
|
||
|
display: flex;
|
||
|
margin: 0;
|
||
|
padding: 0;
|
||
|
}
|
||
|
|
||
|
header nav ul li {
|
||
|
margin: 0 10px;
|
||
|
}
|
||
|
|
||
|
header nav ul li a {
|
||
|
color: white;
|
||
|
text-decoration: none;
|
||
|
font-size: 16px;
|
||
|
}
|
||
|
|
||
|
header nav ul li a:hover {
|
||
|
text-decoration: underline;
|
||
|
}
|
||
|
|
||
|
/* Hero Section */
|
||
|
.hero {
|
||
|
background: url("bloods.jpg") no-repeat center center/cover;
|
||
|
height: 600px;
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
text-align: center;
|
||
|
color: white;
|
||
|
position: relative;
|
||
|
}
|
||
|
|
||
|
.hero::before {
|
||
|
content: "";
|
||
|
position: absolute;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
background-color: rgba(0, 0, 0, 0.5); /* Dark overlay */
|
||
|
}
|
||
|
|
||
|
.hero-content {
|
||
|
z-index: 1;
|
||
|
}
|
||
|
|
||
|
.hero-content h1 {
|
||
|
font-size: 48px;
|
||
|
margin-bottom: 20px;
|
||
|
}
|
||
|
|
||
|
.hero-content button {
|
||
|
background-color: #c62828;
|
||
|
color: white;
|
||
|
padding: 12px 20px;
|
||
|
font-size: 18px;
|
||
|
border: none;
|
||
|
border-radius: 5px;
|
||
|
cursor: pointer;
|
||
|
transition: background-color 0.3s ease;
|
||
|
}
|
||
|
|
||
|
/* Hidden Form */
|
||
|
#donation-form {
|
||
|
display: none;
|
||
|
}
|
||
|
|
||
|
/* Container */
|
||
|
.container {
|
||
|
max-width: 800px;
|
||
|
margin: 40px auto;
|
||
|
padding: 20px;
|
||
|
background-color: white;
|
||
|
border-radius: 8px;
|
||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||
|
}
|
||
|
|
||
|
.container h2 {
|
||
|
text-align: center;
|
||
|
margin-bottom: 20px;
|
||
|
}
|
||
|
|
||
|
.donation-form {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
gap: 15px;
|
||
|
}
|
||
|
|
||
|
.donation-form label {
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
|
||
|
.donation-form input,
|
||
|
.donation-form select,
|
||
|
.donation-form textarea {
|
||
|
width: 100%;
|
||
|
padding: 10px;
|
||
|
border: 1px solid #ccc;
|
||
|
border-radius: 5px;
|
||
|
}
|
||
|
|
||
|
.donation-form button {
|
||
|
background-color: #2fd371;
|
||
|
color: white;
|
||
|
padding: 12px;
|
||
|
font-size: 18px;
|
||
|
border: none;
|
||
|
border-radius: 5px;
|
||
|
cursor: pointer;
|
||
|
transition: background-color 0.3s ease;
|
||
|
}
|
||
|
|
||
|
.donation-form button:hover {
|
||
|
}
|
||
|
|
||
|
/* Footer */
|
||
|
footer {
|
||
|
color: white;
|
||
|
text-align: center;
|
||
|
padding: 10px;
|
||
|
margin-top: 20px;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<section
|
||
|
class="hero"
|
||
|
style="background: url('bloodee.png') no-repeat center center/cover"
|
||
|
>
|
||
|
<div class="hero-content">
|
||
|
<h1>Donate Blood, Save Lives</h1>
|
||
|
<h2>Become a Donor</h2>
|
||
|
<button onclick="showForm()">Click Here</button>
|
||
|
</div>
|
||
|
</section>
|
||
|
|
||
|
<div class="container" id="donation-form">
|
||
|
<h2>Blood Donation Registration</h2>
|
||
|
<form class="donation-form" action="blood.php" method="POST">
|
||
|
<!-- Full Name -->
|
||
|
<label for="name">Full Name:</label>
|
||
|
<input
|
||
|
type="text"
|
||
|
id="name"
|
||
|
name="name"
|
||
|
placeholder="Enter your full name"
|
||
|
value="<?php echo htmlspecialchars($name); ?>"
|
||
|
required
|
||
|
/>
|
||
|
|
||
|
<!-- Age -->
|
||
|
<label for="age">Age:</label>
|
||
|
<input
|
||
|
type="number"
|
||
|
id="age"
|
||
|
name="age"
|
||
|
placeholder="Enter your age"
|
||
|
min="18"
|
||
|
max="65"
|
||
|
value="<?php echo htmlspecialchars($age); ?>"
|
||
|
required
|
||
|
/>
|
||
|
|
||
|
<!-- Blood Group -->
|
||
|
<label for="blood-group">Blood Group:</label>
|
||
|
<select id="blood-group" name="blood-group" required>
|
||
|
<option value="">Select your blood group</option>
|
||
|
<option value="A+" <?php if ($blood_group == 'A+') echo 'selected'; ?>>A+</option>
|
||
|
<option value="A-" <?php if ($blood_group == 'A-') echo 'selected'; ?>>A-</option>
|
||
|
<option value="B+" <?php if ($blood_group == 'B+') echo 'selected'; ?>>B+</option>
|
||
|
<option value="B-" <?php if ($blood_group == 'B-') echo 'selected'; ?>>B-</option>
|
||
|
<option value="O+" <?php if ($blood_group == 'O+') echo 'selected'; ?>>O+</option>
|
||
|
<option value="O-" <?php if ($blood_group == 'O-') echo 'selected'; ?>>O-</option>
|
||
|
<option value="AB+" <?php if ($blood_group == 'AB+') echo 'selected'; ?>>AB+</option>
|
||
|
<option value="AB-" <?php if ($blood_group == 'AB-') echo 'selected'; ?>>AB-</option>
|
||
|
</select>
|
||
|
|
||
|
<!-- Contact Number -->
|
||
|
<label for="contact">Contact Number:</label>
|
||
|
<input
|
||
|
type="tel"
|
||
|
id="contact"
|
||
|
name="contact"
|
||
|
placeholder="Enter your phone number"
|
||
|
value="<?php echo htmlspecialchars($contact); ?>"
|
||
|
required
|
||
|
/>
|
||
|
|
||
|
<!-- Email -->
|
||
|
<label for="email">Email:</label>
|
||
|
<input
|
||
|
type="email"
|
||
|
id="email"
|
||
|
name="email"
|
||
|
placeholder="Enter your email address"
|
||
|
value="<?php echo htmlspecialchars($email); ?>"
|
||
|
required
|
||
|
/>
|
||
|
|
||
|
<!-- Address -->
|
||
|
<label for="address">Address:</label>
|
||
|
<textarea
|
||
|
id="address"
|
||
|
name="address"
|
||
|
rows="3"
|
||
|
placeholder="Enter your complete address"
|
||
|
required
|
||
|
><?php echo htmlspecialchars($address); ?></textarea>
|
||
|
|
||
|
<!-- Submit Button -->
|
||
|
<button type="submit">Register as a Donor</button>
|
||
|
</form>
|
||
|
|
||
|
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
|
||
|
<p>Thank you, <?php echo htmlspecialchars($name); ?>! You have successfully registered as a blood donor.</p>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
function showForm() {
|
||
|
const form = document.getElementById("donation-form");
|
||
|
form.style.display = "block";
|
||
|
form.scrollIntoView({ behavior: "smooth" });
|
||
|
}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|