Finally usable form, mail link in footer

This commit is contained in:
2018-03-27 21:03:17 +03:00
parent 2ea7d832f2
commit d99aa95046
3 changed files with 66 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ok = true;
$grecaptcha_secret_key = '6LcGPU8UAAAAANB2tVqhxbvUSkbxJlOjxLDa8UT4';
if ($_POST['email'] && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$email = $_POST['email'];
} else {
@@ -19,11 +20,47 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ok = false;
echo "<p>Message validation failed</p>";
}
if ($ok) {
// TODO: Sendmail
echo "<p>Validation passed</p>";
if ($_POST['g-recaptcha-response']) {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$params = array(
'secret' => $grecaptcha_secret_key,
'response' => $_POST['g-recaptcha-response'],
);
$result = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
)));
if (!json_decode($result, true)['success']) {
$ok = false;
echo "<p>recaptcha remote validation failed</p>";
}
} else {
echo "<p>Validation failed. Please check your data</p>";
$ok = false;
echo "<p>recaptcha validation failed</p>";
}
if ($ok) {
$ip = $_SERVER["REMOTE_ADDR"];
$message = "Message from $name <$email>, ip: $ip\r\n $body";
$answer = (int)$_POST["answ"];
$headers = 'From: Contact Form <noreply@teamfnd.ru>' . "\r\n" .
'Reply-To: No Reply <noreply@teamfnd.ru>' . "\r\n" .
'Content-Type: text/plain; charset=UTF-8; format=flowed' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('info@teamfnd.ru', "Contact Form on teamfnd.ru from $name <$email>", $message, $headers);
?>
<div style="text-align: center; margin-top: 70px;">
<h1 style="color: green;">Success!</h1>
<p>Your message has been sent.</p>
<p>We will reply you as soon as it is possilble.</p>
<p>You will be redirected back on site soon.</p>
</div>
<?php
echo '<meta http-equiv="refresh" content="4;URL='.$_SERVER['HTTP_REFERER'].'" />';
} else {
echo '<h1 style="color: red;">Validation failed. Please check your data</h1>';
}
} else {
echo 'Method not allowed';

View File

@@ -10,28 +10,28 @@
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(action="http://localhost:8000/contact.php" method="post")
b-form(action="/contact.php" method="post")
b-form-group(id="EmailInputGroup"
label="Email address"
:label="$t('email_address')"
label-for="EmailInput"
description="We'll never share your email with anyone else.")
:description="$t('email_disclaimer')")
b-form-input(id="EmailInput"
type="email"
v-model="form.email"
name="email"
required
placeholder="Enter email")
:placeholder="$t('email_placeholder')")
b-form-group(id="NameInputGroup"
label="Your name:"
:label="$t('your_name')"
label-for="NameInput")
b-form-input(id="NameInput"
type="text"
v-model="form.name"
name="name"
required
placeholder="Enter name")
:placeholder="$t('name_placeholder')")
b-form-group(id="TextInputGroup"
label="Your Message"
:label="$t('your_message')"
label-for="TextInput")
b-form-textarea(id="TextInput"
v-model="form.text"
@@ -41,19 +41,18 @@
:rows="3")
vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed")
p
b-button(type="submit" variant="primary" :disabled="!allowsend") Submit
b-button(type="submit" variant="primary" :disabled="!allowsend") {{$t('submit')}}
b-nav-form
label(for="locale" style="margin: 5px") {{$t('language')}}:
b-form-select(v-model="locale")
option(value="en") English
//option(value="jp") 日本語
option(value="jp") 日本語
option(value="ru") Русский
#app(class="container body-content")
router-view
hr
footer
// TODO: Mailto
p &copy; 2018 TeamFND
p &copy; 2018 TeamFND <a href="mailto:info@teamfnd.ru">info@teamfnd.ru</a>
</template>
<script lang="coffeescript">
@@ -68,7 +67,7 @@ export default
name: ''
text: ''
}
sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
sitekey: '6LcGPU8UAAAAAA0lp61LBl2aTR0k6E_Hf1j4dkHx'
allowsend: false
watch:
locale: (val) ->

View File

@@ -4,6 +4,13 @@ en:
home: "Home"
our_projects: "Our projects"
contact_us: "Contact Us"
email_address: "Email address"
email_disclaimer: "We'll never share your email with anyone else."
email_placeholder: "Enter email"
your_name: "Your name"
name_placeholder: "Enter name"
your_message: "Your Message"
submit: "Submit"
jp:
language: "言語"
about_us: "私たちに関しては"
@@ -15,3 +22,10 @@ ru:
home: "Главная"
our_projects: "Наши проекты"
contact_us: "Связаться с нами"
email_address: "Ваш email"
email_disclaimer: "Мы никому не сообщим ваш email"
email_placeholder: "Введите email"
your_name: "Ваше имя"
name_placeholder: "Введите имя"
your_message: "Ваше сообщение"
submit: "Отправить"