Add volunteer, sign request forms, about portrait, paid for declaration
This commit is contained in:
parent
57ffc3742a
commit
a511651536
@ -1,2 +1,3 @@
|
||||
<h4 class="center">PAID FOR BY MILES C. LINDEN FOR CITY COUNCIL DISTRICT THREE</h4>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -13,7 +13,9 @@
|
||||
<nav id="main-nav">
|
||||
<a href="/#home">Home</a>
|
||||
<a href="/#about">About</a>
|
||||
<a href="/#signs">Signs</a>
|
||||
<a href="/#joinus">Join</a>
|
||||
<a href="/#volunteer">Volunteer</a>
|
||||
<a href="/#donate">Donate</a>
|
||||
<a href="/#contact">Contact</a>
|
||||
</nav>
|
||||
|
@ -30,6 +30,28 @@ $messages = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
$result = $conn->query("SELECT * FROM volunteers");
|
||||
if (!$result) {
|
||||
http_response_code(500);
|
||||
die("Error retrieving volunteers: {$conn->error}");
|
||||
}
|
||||
|
||||
$volunteers = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$volunteers[] = $row;
|
||||
}
|
||||
|
||||
$result = $conn->query("SELECT * FROM signs");
|
||||
if (!$result) {
|
||||
http_response_code(500);
|
||||
die("Error retrieving sign requests: {$conn->error}");
|
||||
}
|
||||
|
||||
$signs = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$signs[] = $row;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
@ -116,6 +138,70 @@ while ($row = $result->fetch_assoc()) {
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Volunteers</h2>
|
||||
<table cellpadding="5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Position</th>
|
||||
<th>Join Date</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($volunteers as $row) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($row['full_name']) ?></td>
|
||||
<td>
|
||||
<a href="mailto:<?= htmlspecialchars($row['email']) ?>"><?= htmlspecialchars($row['email']) ?></a></td>
|
||||
<td><?= htmlspecialchars($row['phone']) ?></td>
|
||||
<td><?= htmlspecialchars($row['position']) ?></td>
|
||||
<td><?= htmlspecialchars($row['join_date']) ?></td>
|
||||
<td>
|
||||
<!--<button class="deleteEmail" data-email="<?= htmlspecialchars($row['email']) ?>">Delete</button>-->
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Sign Requests</h2>
|
||||
<table cellpadding="5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
<th>Quantity</th>
|
||||
<th>Wire stake?</th>
|
||||
<th>Fulfilled?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($signs as $row) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($row['address']) ?></td>
|
||||
<td><?= $row['quantity'] ?></td>
|
||||
<td><?= $row['wire_stake'] ?></td>
|
||||
<td><?= $row['fulfilled'] ?></td>
|
||||
<td>
|
||||
<!--<button class="fulfillRequest" data-address="<?= htmlspecialchars($row['address']) ?>">Fulfilled</button>-->
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
BIN
public/assets/portrait.png
Normal file
BIN
public/assets/portrait.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 206 KiB |
@ -54,6 +54,10 @@ a {
|
||||
|
||||
#landing {
|
||||
display: block !important;
|
||||
/*background-image: url(/assets/portrait.png);*/
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: right;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
#landing-mobile {
|
||||
@ -179,6 +183,11 @@ a {
|
||||
|
||||
.main-banner {
|
||||
background-color: var(--banner-bg);
|
||||
/*background-image: url(/assets/portrait.png);*/
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: right;
|
||||
background-size: contain;
|
||||
background-position-y: bottom;
|
||||
padding: 1rem;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
@ -315,6 +324,18 @@ nav a:hover {
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
.banner form input[type="number"] {
|
||||
min-width: unset;
|
||||
max-width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.banner form input[type="checkbox"] {
|
||||
display: inline;
|
||||
min-width: unset;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.banner form input.invalid, .banner form textarea.invalid {
|
||||
border-bottom-color: red;
|
||||
}
|
||||
@ -346,7 +367,6 @@ nav a:hover {
|
||||
.fullpage {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.panel {
|
||||
@ -365,7 +385,7 @@ nav a:hover {
|
||||
}
|
||||
|
||||
.panel img {
|
||||
width: 80%;
|
||||
max-height: 60%;
|
||||
margin: 1rem auto;
|
||||
display: block;
|
||||
}
|
||||
@ -399,23 +419,22 @@ nav a:hover {
|
||||
}
|
||||
|
||||
#about {
|
||||
background-image: url(../assets/civic.jpg);
|
||||
/*background-image: url(../assets/civic.jpg);*/
|
||||
}
|
||||
|
||||
#contact {
|
||||
background-image: url(../assets/myles.jpg);
|
||||
/*background-image: url(../assets/myles.jpg);*/
|
||||
}
|
||||
|
||||
#donate {
|
||||
background-image: url(../assets/carwash.jpg);
|
||||
/*background-image: url(../assets/carwash.jpg);*/
|
||||
}
|
||||
|
||||
#donate h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#joinus {
|
||||
background-image: url(../assets/bote.jpg);
|
||||
#joinus, #volunteer, #signs {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -443,7 +462,7 @@ nav a:hover {
|
||||
padding: 0 2rem;
|
||||
margin: 0 auto 2rem auto;
|
||||
text-align: center;
|
||||
max-width: 300px;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
#donate .banner {
|
||||
|
@ -4,8 +4,8 @@
|
||||
<div class="main-banner">
|
||||
<img src="assets/myles-logo.png">
|
||||
<div class="main-banner-buttons">
|
||||
<a href="#donate">Donate</a>
|
||||
<a href="#joinus">Join</a>
|
||||
<a href="/#donate">Donate</a>
|
||||
<a href="/#joinus">Join</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -29,7 +29,9 @@
|
||||
<div class="main-banner-content">
|
||||
<div id="mobile-nav-menu">
|
||||
<a href="/#about">About</a>
|
||||
<a href="/#signs">Signs</a>
|
||||
<a href="/#joinus">Join</a>
|
||||
<a href="/#volunteer">Volunteer</a>
|
||||
<a href="/#donate">Donate</a>
|
||||
<a href="/#contact">Contact</a>
|
||||
</div>
|
||||
@ -43,8 +45,8 @@
|
||||
<div id="about" class="fullpage">
|
||||
<div class="panel">
|
||||
<h1>About Miles</h1>
|
||||
<img src="assets/myles.png" height="200">
|
||||
<p>About box description</p>
|
||||
<img src="assets/portrait.png">
|
||||
<p>Miles is a working class member of District Three and truly understands the the biggest issues facing our community. Miles will not let anything get in the way of improving our standard of living, and the safety of our neighborhoods.</p>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="center">
|
||||
@ -64,6 +66,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="signs" class="fullpage">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Request a Sign</h1>
|
||||
</div>
|
||||
<div class="banner">
|
||||
<form id="signForm" action="/requestSign.php" method="POST">
|
||||
<div>
|
||||
<input type="text" name="address" placeholder="Address" required>
|
||||
</div>
|
||||
<div>
|
||||
<label>Quantity</label>
|
||||
<input type="number" min="1" name="quantity" placeholder="1" value="1" required>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Would you like a wire stake?
|
||||
<input type="checkbox" name="wire_stake" required>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit">Request</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="joinus" class="fullpage">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
@ -87,6 +116,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="volunteer" class="fullpage">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Volunteer</h1>
|
||||
</div>
|
||||
<div class="banner">
|
||||
<form id="volunteerForm" action="/volunteer.php" method="POST">
|
||||
<div>
|
||||
<input type="text" name="full_name" placeholder="Full Name" required>
|
||||
</div>
|
||||
<div>
|
||||
<input type="email" name="email" placeholder="Email" required>
|
||||
</div>
|
||||
<div>
|
||||
<input type="tel" name="phone" placeholder="Phone Number" required>
|
||||
</div>
|
||||
<div>
|
||||
<select name="position">
|
||||
<option selected>Choose a Position...</option>
|
||||
<option value="Flyer Distributor">Flyer Distributor</option>
|
||||
<option value="Social Media">Social Media</option>
|
||||
<option value="Sign Setter">Sign Setter</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit">Sign Up</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="donate" class="fullpage">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
|
@ -130,5 +130,7 @@ function registerHamburgers() {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
registerFormValidators('subscribeForm');
|
||||
registerFormValidators('contactForm');
|
||||
registerFormValidators('signForm');
|
||||
registerFormValidators('volunteerForm');
|
||||
registerHamburgers();
|
||||
});
|
||||
|
80
public/requestSign.php
Normal file
80
public/requestSign.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
session_set_cookie_params(3600);
|
||||
session_start();
|
||||
|
||||
$address = $_POST['address'];
|
||||
$quantity = $_POST['quantity'];
|
||||
$wire = $_POST['wire_stake'];
|
||||
|
||||
if (!isset($address) || strlen($address) === 0) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'address',
|
||||
'message' => 'Error: A valid address is required.'
|
||||
]));
|
||||
}
|
||||
if (!isset($quantity) || (int) $quantity <= 0) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'quantity',
|
||||
'message' => 'Error: A quantity is required.'
|
||||
]));
|
||||
}
|
||||
if (!isset($wire)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'wire_stake',
|
||||
'message' => 'Error: Wire stake preference needs to be specified.'
|
||||
]));
|
||||
}
|
||||
|
||||
$conn = new mysqli("localhost", "mileslinden", "Daiso@6969", "mileslinden");
|
||||
|
||||
$query = $conn->prepare(
|
||||
"INSERT INTO subscribers (`address`, `quantity`, `wire_stake`, `join_date`) VALUES (?, ?, ?, ?)"
|
||||
);
|
||||
if (!$query) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => $conn->error]));
|
||||
}
|
||||
if (!isset($_SESSION['signs'])) {
|
||||
$_SESSION['signs'] = 0;
|
||||
} else if ($_SESSION['signs'] >= 5) {
|
||||
http_response_code(429);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => 'You are requesting signs too often.']));
|
||||
}
|
||||
$query->bind_param(
|
||||
"sibs",
|
||||
$address, $quantity, $wire,
|
||||
date("Y-m-d H:i:s")
|
||||
);
|
||||
if (!$query->execute()) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
if ($query->errno === 1062) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => 'This address has already requested a sign.', 'field' => 'address']));
|
||||
} else {
|
||||
die(json_encode(['message' => $query->error, 'errno' => $query->errno]));
|
||||
}
|
||||
}
|
||||
$_SESSION['signs']++;
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Miles Linden for San Jose City Council</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>You have requested a sign successfully.</h1>
|
||||
</body>
|
||||
</html>
|
106
public/volunteer.php
Normal file
106
public/volunteer.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
session_set_cookie_params(3600);
|
||||
session_start();
|
||||
|
||||
$email = $_POST['email'];
|
||||
$fname = $_POST['full_name'];
|
||||
$phone = $_POST['phone'];
|
||||
$position = $_POST['position'];
|
||||
|
||||
$pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-+[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-+[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD';
|
||||
|
||||
if (!isset($phone)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'phone',
|
||||
'message' => 'Error: A phone number is required.'
|
||||
]));
|
||||
}
|
||||
//eliminate every char except 0-9
|
||||
$phone_num = preg_replace("/[^0-9]/", '', $phone);
|
||||
|
||||
//eliminate leading 1 if its there
|
||||
if (strlen($phone_num) == 11)
|
||||
$phone_num = preg_replace("/^1/", '', $phone_num);
|
||||
|
||||
if (!isset($email) || preg_match($pattern, $email) !== 1) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'email',
|
||||
'message' => 'Error: A valid email address is required.'
|
||||
]));
|
||||
}
|
||||
if (!isset($fname)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'full_name',
|
||||
'message' => 'Error: A first and last name are required.'
|
||||
]));
|
||||
}
|
||||
if (!isset($position)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'full_name',
|
||||
'message' => 'Error: A volunteer position is required.'
|
||||
]));
|
||||
}
|
||||
if (strlen($phone_num) !== 10) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'field' => 'phone',
|
||||
'message' => 'Error: This phone number is invalid.'
|
||||
]));
|
||||
}
|
||||
|
||||
$conn = new mysqli("localhost", "mileslinden", "Daiso@6969", "mileslinden");
|
||||
|
||||
$query = $conn->prepare(
|
||||
"INSERT INTO subscribers (`email`, `full_name`, `phone`, `position`, `join_date`) VALUES (?, ?, ?, ?, ?)"
|
||||
);
|
||||
if (!$query) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => $conn->error]));
|
||||
}
|
||||
if (!isset($_SESSION['volunteers'])) {
|
||||
$_SESSION['volunteers'] = 0;
|
||||
} else if ($_SESSION['volunteers'] >= 5) {
|
||||
http_response_code(429);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => 'You are volunteering too often.']));
|
||||
}
|
||||
$query->bind_param(
|
||||
"sssss",
|
||||
$email, $fname, $phone_num, $position,
|
||||
date("Y-m-d H:i:s")
|
||||
);
|
||||
if (!$query->execute()) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
if ($query->errno === 1062) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['message' => 'This email is already a volunteer.', 'field' => 'email']));
|
||||
} else {
|
||||
die(json_encode(['message' => $query->error, 'errno' => $query->errno]));
|
||||
}
|
||||
}
|
||||
$_SESSION['volunteers']++;
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Miles Linden for San Jose City Council</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>You have signed up as a volunteer successfully.</h1>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user