Form subscribe checkbox

This commit is contained in:
Yves Gatesoupe 2020-07-08 17:07:15 +02:00
parent 0b9784dbe7
commit 452b9bee54
3 changed files with 11 additions and 5 deletions

View File

@ -142,7 +142,7 @@
{% if option.value %}
<label for="field-{{ name }}-{{ option.value }}">
<input type="checkbox"
name="{{ name }}[]"
name="{{ name }}"
id="field-{{ name }}-{{ option.value }}"
value="{{ option.value }}"
{% if option.note %}aria-describedby="description-{{ name }}-{{ option.value }}"{% endif %}
@ -150,7 +150,7 @@
{% else %}
<label for="field-{{ name }}-{{ option }}">
<input type="checkbox"
name="{{ name }}[]"
name="{{ name }}"
id="field-{{ name }}-{{ option }}"
value="{{ option }}"
>{{ option }}</label>

View File

@ -31,9 +31,9 @@
{{ label("Votre message", "message") }}
{{ textarea( "message", { required: true, autocapitalize: "sentences", spellcheck: "true" } ) }}
</li>
{# <li class="[ field-list__field-group ] [ full-width ]">
{{ checkboxes("", "field-checkbox-name", [ "Je souhaite être tenu au courant de lactualité Astrolabe"], { description: "" } ) }}
</li> #}
<li class="[ field-list__field-group ] [ full-width ]">
{{ checkboxes("", "subscribe", [ "Je souhaite être tenu au courant de lactualité Astrolabe"], { description: "" } ) }}
</li>
{# <li hidden>
<label>Dont fill this out if you're human: <input name="bot-field" /></label>
</li> #}

View File

@ -10,6 +10,7 @@
$emailAddress = $_POST['email'];
$select = $_POST['select'];
$message = $_POST['message'];
$subscribe = $_POST['subscribe'];
if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
$errors .= "\n Error: Invalid email address $emailAddress";
@ -53,6 +54,11 @@
// send the email
mail($to, $emailSubject, $emailBodyHTML, implode("\r\n", $headers));
// if subscribe add to mailing list
if(!empty($subscribe)) {
// process
}
// redirect to the 'thank you' page
header("Location: /thank-you/index.html");