From 2ea7d832f29d852e4017afcec9dc17dcac318984 Mon Sep 17 00:00:00 2001 From: Vladislav Utkin Date: Tue, 27 Mar 2018 01:28:46 +0300 Subject: [PATCH] Add sendmail script WIP --- contact.php | 31 +++++++++++++++++++++++++++++++ src/App.vue | 19 +++++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 contact.php diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..9f7bc6a --- /dev/null +++ b/contact.php @@ -0,0 +1,31 @@ +Email validation failed

"; + } + if ($_POST['name'] && strlen($_POST['name']) <= 30) { + $name = htmlspecialchars($_POST['name']); + } else { + $ok = false; + echo "

Name validation failed

"; + } + if ($_POST['body'] && strlen($_POST['body']) <= 2000) { + $body = htmlspecialchars($_POST['body']); + } else { + $ok = false; + echo "

Message validation failed

"; + } + if ($ok) { + // TODO: Sendmail + echo "

Validation passed

"; + } else { + echo "

Validation failed. Please check your data

"; + } +} else { + echo 'Method not allowed'; +} +?> diff --git a/src/App.vue b/src/App.vue index c22282f..5b08a50 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,7 +10,7 @@ b-navbar-nav(class="ml-auto") b-nav-item(@click="modalShow = !modalShow") {{$t('contact_us')}} b-modal(id="contactus" hide-footer :title="$t('contact_us')" v-model="modalShow") - b-form(@sumbit="send") + b-form(action="http://localhost:8000/contact.php" method="post") b-form-group(id="EmailInputGroup" label="Email address" label-for="EmailInput" @@ -18,6 +18,7 @@ b-form-input(id="EmailInput" type="email" v-model="form.email" + name="email" required placeholder="Enter email") b-form-group(id="NameInputGroup" @@ -26,6 +27,7 @@ b-form-input(id="NameInput" type="text" v-model="form.name" + name="name" required placeholder="Enter name") b-form-group(id="TextInputGroup" @@ -33,12 +35,13 @@ label-for="TextInput") b-form-textarea(id="TextInput" v-model="form.text" + name="body" required placeholder="" :rows="3") - vue-recaptcha(:sitekey="sitekey" @verify="captchaPass") + vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed") p - b-button(type="submit" variant="primary" @click.prevent="send") Submit + b-button(type="submit" variant="primary" :disabled="!allowsend") Submit b-nav-form label(for="locale" style="margin: 5px") {{$t('language')}}: b-form-select(v-model="locale") @@ -49,6 +52,7 @@ router-view hr footer + // TODO: Mailto p © 2018 TeamFND @@ -63,20 +67,19 @@ export default email: '' name: '' text: '' - captcha_challenge: '' } sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' + allowsend: false watch: locale: (val) -> this.$root.$i18n.locale = val window.localStorage.language = val methods: - send: (evt) -> - # TODO: Check data - console.log(JSON.stringify(@form)) - @modalShow = !@modalShow captchaPass: (key) -> @form.captcha_challenge = key + @allowsend = true + captchaFailed: () -> + @allowsend = false components: { VueRecaptcha }