Unverified Commit a90bce9b authored by Jean-Claude Graf's avatar Jean-Claude Graf
Browse files

NEW: handle post in PHP and display confirmation/error

parent 319ba5c7
<?php
include "../src/bootstrap.php";
$error = FALSE;
$success = FALSE;
if (isset($_POST["email"])) {
$url = 'https://admin.hostpoint.ch/mailman/subscribe/events_thealternative.ch';
$data = array('email' => $_POST["email"], 'fullname' => $_POST["fullname"], 'pw' => "", 'pw-conf' => "");
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
$error = TRUE;
} else {
$success = TRUE;
}
}
?>
<!DOCTYPE html>
<html lang="en">
......@@ -21,7 +45,16 @@ include "../templates/header.html"
<div class="page-content">
<p>You will receive information about all upcoming events at the beginning of each semester, as well as a reminder one day before each event. We will not spam you.</br>
You can leave the mailing list anytime again.</p>
<form method="post" action="https://admin.hostpoint.ch/mailman/subscribe/events_thealternative.ch">
<form method="post" action="/mailinglist.php">
<?php if ($success) { ?>
<div class="alert alert-success">
Great to see you joining our mailing list. Pleas check your mails to confirm you sign up!
</div>
<?php } else if ($error) { ?>
<div class="alert alert-error">
Error signing up. Please contact us directly.
</div>
<?php } ?>
<div class="form-group">
<label for="inputEmail">Email Address</label>
<input name="email" type="email" class="form-control" id="inputEmail" aria-describedby="emailHelp" placeholder="Enter email" required>
......@@ -32,11 +65,7 @@ include "../templates/header.html"
<input name="fullname" type="text" class="form-control" id="inputName" aria-describedby="nameHelp" placeholder="First Name">
<small id="nameHelp" class="form-text text-muted">We'll only use it to address you by our name.</small>
</div>
<div class="form-group">
<input type="hidden" name="pw" value="">
<input type="hidden" name="pw-conf" value="">
</div>
<button type="submit" name="email-button" class="btn btn-primary">Submit</button>
<button type="submit" name="email-button" class="btn btn-primary">Sign Up</button>
</form>
</div>
</div>
......@@ -46,5 +75,6 @@ include "../templates/header.html"
include "../templates/scripts.html"
?>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment