Finally usable form, mail link in footer
This commit is contained in:
45
contact.php
45
contact.php
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
$grecaptcha_secret_key = '6LcGPU8UAAAAANB2tVqhxbvUSkbxJlOjxLDa8UT4';
|
||||||
if ($_POST['email'] && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
if ($_POST['email'] && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
$email = $_POST['email'];
|
$email = $_POST['email'];
|
||||||
} else {
|
} else {
|
||||||
@@ -19,11 +20,47 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$ok = false;
|
$ok = false;
|
||||||
echo "<p>Message validation failed</p>";
|
echo "<p>Message validation failed</p>";
|
||||||
}
|
}
|
||||||
if ($ok) {
|
if ($_POST['g-recaptcha-response']) {
|
||||||
// TODO: Sendmail
|
$url = 'https://www.google.com/recaptcha/api/siteverify';
|
||||||
echo "<p>Validation passed</p>";
|
$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 {
|
} 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 {
|
} else {
|
||||||
echo 'Method not allowed';
|
echo 'Method not allowed';
|
||||||
|
|||||||
23
src/App.vue
23
src/App.vue
@@ -10,28 +10,28 @@
|
|||||||
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(action="http://localhost:8000/contact.php" method="post")
|
b-form(action="/contact.php" method="post")
|
||||||
b-form-group(id="EmailInputGroup"
|
b-form-group(id="EmailInputGroup"
|
||||||
label="Email address"
|
:label="$t('email_address')"
|
||||||
label-for="EmailInput"
|
label-for="EmailInput"
|
||||||
description="We'll never share your email with anyone else.")
|
:description="$t('email_disclaimer')")
|
||||||
b-form-input(id="EmailInput"
|
b-form-input(id="EmailInput"
|
||||||
type="email"
|
type="email"
|
||||||
v-model="form.email"
|
v-model="form.email"
|
||||||
name="email"
|
name="email"
|
||||||
required
|
required
|
||||||
placeholder="Enter email")
|
:placeholder="$t('email_placeholder')")
|
||||||
b-form-group(id="NameInputGroup"
|
b-form-group(id="NameInputGroup"
|
||||||
label="Your name:"
|
:label="$t('your_name')"
|
||||||
label-for="NameInput")
|
label-for="NameInput")
|
||||||
b-form-input(id="NameInput"
|
b-form-input(id="NameInput"
|
||||||
type="text"
|
type="text"
|
||||||
v-model="form.name"
|
v-model="form.name"
|
||||||
name="name"
|
name="name"
|
||||||
required
|
required
|
||||||
placeholder="Enter name")
|
:placeholder="$t('name_placeholder')")
|
||||||
b-form-group(id="TextInputGroup"
|
b-form-group(id="TextInputGroup"
|
||||||
label="Your Message"
|
:label="$t('your_message')"
|
||||||
label-for="TextInput")
|
label-for="TextInput")
|
||||||
b-form-textarea(id="TextInput"
|
b-form-textarea(id="TextInput"
|
||||||
v-model="form.text"
|
v-model="form.text"
|
||||||
@@ -41,19 +41,18 @@
|
|||||||
:rows="3")
|
:rows="3")
|
||||||
vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed")
|
vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed")
|
||||||
p
|
p
|
||||||
b-button(type="submit" variant="primary" :disabled="!allowsend") Submit
|
b-button(type="submit" variant="primary" :disabled="!allowsend") {{$t('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")
|
||||||
option(value="en") English
|
option(value="en") English
|
||||||
//option(value="jp") 日本語
|
option(value="jp") 日本語
|
||||||
option(value="ru") Русский
|
option(value="ru") Русский
|
||||||
#app(class="container body-content")
|
#app(class="container body-content")
|
||||||
router-view
|
router-view
|
||||||
hr
|
hr
|
||||||
footer
|
footer
|
||||||
// TODO: Mailto
|
p © 2018 TeamFND <a href="mailto:info@teamfnd.ru">info@teamfnd.ru</a>
|
||||||
p © 2018 TeamFND
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="coffeescript">
|
<script lang="coffeescript">
|
||||||
@@ -68,7 +67,7 @@ export default
|
|||||||
name: ''
|
name: ''
|
||||||
text: ''
|
text: ''
|
||||||
}
|
}
|
||||||
sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
|
sitekey: '6LcGPU8UAAAAAA0lp61LBl2aTR0k6E_Hf1j4dkHx'
|
||||||
allowsend: false
|
allowsend: false
|
||||||
watch:
|
watch:
|
||||||
locale: (val) ->
|
locale: (val) ->
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ en:
|
|||||||
home: "Home"
|
home: "Home"
|
||||||
our_projects: "Our projects"
|
our_projects: "Our projects"
|
||||||
contact_us: "Contact Us"
|
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:
|
jp:
|
||||||
language: "言語"
|
language: "言語"
|
||||||
about_us: "私たちに関しては"
|
about_us: "私たちに関しては"
|
||||||
@@ -15,3 +22,10 @@ ru:
|
|||||||
home: "Главная"
|
home: "Главная"
|
||||||
our_projects: "Наши проекты"
|
our_projects: "Наши проекты"
|
||||||
contact_us: "Связаться с нами"
|
contact_us: "Связаться с нами"
|
||||||
|
email_address: "Ваш email"
|
||||||
|
email_disclaimer: "Мы никому не сообщим ваш email"
|
||||||
|
email_placeholder: "Введите email"
|
||||||
|
your_name: "Ваше имя"
|
||||||
|
name_placeholder: "Введите имя"
|
||||||
|
your_message: "Ваше сообщение"
|
||||||
|
submit: "Отправить"
|
||||||
|
|||||||
Reference in New Issue
Block a user