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

View File

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

View File

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