Add reCAPTCHA V2
This commit is contained in:
parent
78762aa0fa
commit
047f7a6f03
@ -9,9 +9,9 @@ if($_POST) {
|
|||||||
$email = trim(stripslashes($_POST['contactEmail']));
|
$email = trim(stripslashes($_POST['contactEmail']));
|
||||||
$subject = trim(stripslashes($_POST['contactSubject']));
|
$subject = trim(stripslashes($_POST['contactSubject']));
|
||||||
$contact_message = trim(stripslashes($_POST['contactMessage']));
|
$contact_message = trim(stripslashes($_POST['contactMessage']));
|
||||||
// if(isset($_POST['contactCaptcha'])){
|
if(isset($_POST['contactCaptcha'])){
|
||||||
// $captcha = $_POST['contactCaptcha'];
|
$captcha = $_POST['contactCaptcha'];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Check Name
|
// Check Name
|
||||||
if (strlen($name) < 2) {
|
if (strlen($name) < 2) {
|
||||||
@ -26,14 +26,14 @@ if($_POST) {
|
|||||||
$error['message'] = "Please enter your message. It should have at least 10 characters.";
|
$error['message'] = "Please enter your message. It should have at least 10 characters.";
|
||||||
}
|
}
|
||||||
// Captcha
|
// Captcha
|
||||||
// if (!$captcha){
|
if (!$captcha){
|
||||||
// $error['captcha'] = "Please check the CAPTCHA field.";
|
$error['captcha'] = "Please check the CAPTCHA field.";
|
||||||
// } else {
|
} else {
|
||||||
$captchaResponse = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Le7VisUAAAAAKExpdr5NJy8AHGM0Y3iPI1eVZgD&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
|
$captchaResponse = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Le1wRcTAAAAADbdnvPLKQ_hupTI4jzaGGXFQhQA&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
|
||||||
if($captchaResponse['success'] == false) {
|
if($captchaResponse['success'] == false) {
|
||||||
$error['captcha'] = "You are a robot.";
|
$error['captcha'] = "You are a robot.";
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
$mail = new PHPMailer;
|
$mail = new PHPMailer;
|
||||||
|
|
||||||
|
15
index.html
15
index.html
@ -3,7 +3,7 @@
|
|||||||
<!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
|
<!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
|
||||||
<!--[if (gte IE 8)|!(IE)]><!-->
|
<!--[if (gte IE 8)|!(IE)]><!-->
|
||||||
<html class="no-js" lang="en"> <!--<![endif]-->
|
<html class="no-js" lang="en"> <!--<![endif]-->
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Theme: Ceevee
|
Theme: Ceevee
|
||||||
@ -62,9 +62,9 @@
|
|||||||
================================================== -->
|
================================================== -->
|
||||||
<link rel="shortcut icon" href="images/favicon.ico" >
|
<link rel="shortcut icon" href="images/favicon.ico" >
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<!-- Header
|
<!-- Header
|
||||||
Photo: Play Among The Stars
|
Photo: Play Among The Stars
|
||||||
By David L. Labrie — National Geographic Your Shot
|
By David L. Labrie — National Geographic Your Shot
|
||||||
@ -391,11 +391,8 @@
|
|||||||
<input type="text" value="" size="35" maxlength="100" id="contactEmail" name="contactEmail" placeholder="Email (required)">
|
<input type="text" value="" size="35" maxlength="100" id="contactEmail" name="contactEmail" placeholder="Email (required)">
|
||||||
<input type="text" value="" size="35" maxlength="100" id="contactSubject" name="contactSubject" placeholder="Subject">
|
<input type="text" value="" size="35" maxlength="100" id="contactSubject" name="contactSubject" placeholder="Subject">
|
||||||
<textarea cols="50" rows="15" maxlength="1500" id="contactMessage" name="contactMessage" placeholder="Message" style="resize: vertical; font-family: inherit; font-size: inherit"></textarea>
|
<textarea cols="50" rows="15" maxlength="1500" id="contactMessage" name="contactMessage" placeholder="Message" style="resize: vertical; font-family: inherit; font-size: inherit"></textarea>
|
||||||
<button
|
<div id="g-recaptcha" class="g-recaptcha" data-theme="dark" data-sitekey="6Le1wRcTAAAAAMOmewHOghJved-nNQOq-1ro7vtc"></div><br/>
|
||||||
class="g-recaptcha submit"
|
<button class="submit">Submit</button>
|
||||||
data-sitekey="6Le7VisUAAAAAIn3TfNvR6srMLuVa6Xw09zojiIt">
|
|
||||||
Submit
|
|
||||||
</button>
|
|
||||||
<span id="image-loader">
|
<span id="image-loader">
|
||||||
<img alt="" src="images/loader.gif">
|
<img alt="" src="images/loader.gif">
|
||||||
</span>
|
</span>
|
||||||
@ -449,6 +446,6 @@
|
|||||||
<script src="js/magnific-popup.js"></script>
|
<script src="js/magnific-popup.js"></script>
|
||||||
<script src="js/init.js"></script>
|
<script src="js/init.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -171,12 +171,11 @@ jQuery(document).ready(function($) {
|
|||||||
$('#image-loader').fadeOut();
|
$('#image-loader').fadeOut();
|
||||||
$('#message-warning').html(msg);
|
$('#message-warning').html(msg);
|
||||||
$('#message-warning').fadeIn();
|
$('#message-warning').fadeIn();
|
||||||
|
}
|
||||||
grecaptcha.reset();
|
grecaptcha.reset();
|
||||||
$('form#contactForm button.submit').prop('disabled', false);
|
$('form#contactForm button.submit').prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user