Add sendmail script WIP

This commit is contained in:
2018-03-27 01:28:46 +03:00
parent 2ce8aa5e3e
commit 2ea7d832f2
2 changed files with 42 additions and 8 deletions

31
contact.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ok = true;
if ($_POST['email'] && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$email = $_POST['email'];
} else {
$ok = false;
echo "<p>Email validation failed</p>";
}
if ($_POST['name'] && strlen($_POST['name']) <= 30) {
$name = htmlspecialchars($_POST['name']);
} else {
$ok = false;
echo "<p>Name validation failed</p>";
}
if ($_POST['body'] && strlen($_POST['body']) <= 2000) {
$body = htmlspecialchars($_POST['body']);
} else {
$ok = false;
echo "<p>Message validation failed</p>";
}
if ($ok) {
// TODO: Sendmail
echo "<p>Validation passed</p>";
} else {
echo "<p>Validation failed. Please check your data</p>";
}
} else {
echo 'Method not allowed';
}
?>

View File

@@ -10,7 +10,7 @@
b-navbar-nav(class="ml-auto") b-navbar-nav(class="ml-auto")
b-nav-item(@click="modalShow = !modalShow") {{$t('contact_us')}} b-nav-item(@click="modalShow = !modalShow") {{$t('contact_us')}}
b-modal(id="contactus" hide-footer :title="$t('contact_us')" v-model="modalShow") 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" b-form-group(id="EmailInputGroup"
label="Email address" label="Email address"
label-for="EmailInput" label-for="EmailInput"
@@ -18,6 +18,7 @@
b-form-input(id="EmailInput" b-form-input(id="EmailInput"
type="email" type="email"
v-model="form.email" v-model="form.email"
name="email"
required required
placeholder="Enter email") placeholder="Enter email")
b-form-group(id="NameInputGroup" b-form-group(id="NameInputGroup"
@@ -26,6 +27,7 @@
b-form-input(id="NameInput" b-form-input(id="NameInput"
type="text" type="text"
v-model="form.name" v-model="form.name"
name="name"
required required
placeholder="Enter name") placeholder="Enter name")
b-form-group(id="TextInputGroup" b-form-group(id="TextInputGroup"
@@ -33,12 +35,13 @@
label-for="TextInput") label-for="TextInput")
b-form-textarea(id="TextInput" b-form-textarea(id="TextInput"
v-model="form.text" v-model="form.text"
name="body"
required required
placeholder="" placeholder=""
:rows="3") :rows="3")
vue-recaptcha(:sitekey="sitekey" @verify="captchaPass") vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed")
p p
b-button(type="submit" variant="primary" @click.prevent="send") Submit b-button(type="submit" variant="primary" :disabled="!allowsend") Submit
b-nav-form b-nav-form
label(for="locale" style="margin: 5px") {{$t('language')}}: label(for="locale" style="margin: 5px") {{$t('language')}}:
b-form-select(v-model="locale") b-form-select(v-model="locale")
@@ -49,6 +52,7 @@
router-view router-view
hr hr
footer footer
// TODO: Mailto
p &copy; 2018 TeamFND p &copy; 2018 TeamFND
</template> </template>
@@ -63,20 +67,19 @@ export default
email: '' email: ''
name: '' name: ''
text: '' text: ''
captcha_challenge: ''
} }
sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
allowsend: false
watch: watch:
locale: (val) -> locale: (val) ->
this.$root.$i18n.locale = val this.$root.$i18n.locale = val
window.localStorage.language = val window.localStorage.language = val
methods: methods:
send: (evt) ->
# TODO: Check data
console.log(JSON.stringify(@form))
@modalShow = !@modalShow
captchaPass: (key) -> captchaPass: (key) ->
@form.captcha_challenge = key @form.captcha_challenge = key
@allowsend = true
captchaFailed: () ->
@allowsend = false
components: { VueRecaptcha } components: { VueRecaptcha }
</script> </script>