Answer the question
In order to leave comments, you need to log in
Who can help with installing recaptcha?
help me understand the code there is such a code
form
<div id="base-modal" class="modal fade" tabindex="-1" data-width="420">
<form action="/users/login" url="/" method="POST" class="form_0" style="padding:0px; margin:0px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">{lang=Авторизация}</h4>
</div>
<div class="modal-body">
<input style="width:100%;" class="form-control" name="data[email]" placeholder="E-mail" type="text">
<br>
<input style="width:100%;" class="form-control" name="data[password]" type="password" placeholder="{lang=Пароль}">
</div>
<div class="modal-footer">
<div class="g-recaptcha" data-sitekey="6LdjULAUAAAAACwf3s0akZURbxhvJd09mw8oAFX3"></div>
<a href="/users/signup" class="btn btn-default ymodal">{lang=Регистрация}</a>
<a href="/users/recovery" class="btn btn-default ymodal">{lang=Восстановить}</a>
<button type="submit" class="btn btn-primary">{lang=Войти}</button>
<a type="submit" class="btn btn-icon-only blue loginvk"><i class="fa fa-vk"></i></a>
</div>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
$("form").submit(function(e){
e.preventDefault();
var login = $("input").val();
$.ajax({
url: 'handler.php',
type: "post",
data: "login=" + login + "&g-recaptcha-response=" + grecaptcha.getResponse(),
success: function(data) {
if(data === 'ok') {
window.location.href ='/';
} else {
console.log(data);
}
}
})
});
</script>
<?php
if($_POST['g-recaptcha-response']) {
$captcha = $_POST['g-recaptcha-response'];
$secret = "6LdjULAUAAAAAJ09xC7TUnFK41VIi8CoTOMEfAwi";
$json = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=". $secret . "&response=" . $captcha), true);
if($json['success']) {
echo "ok";
} else {
echo "recaptcha error";
}
} else {
echo "Вы не ввели значение recaptcha";
}
?>
$(document).on('submit', '.form_0', function (e) {
e.preventDefault();
var url = $(this).attr('url');
$(this).ajaxSubmit({
dataType: 'json',
data: {ajax_f: '1'},
success: function (data) {
ajax_result(data);
if (data.r) {
href_go(url);
}
},
beforeSend: function () {
$('.preloader-bar').css('top','0px');
$('#loader-ajax').css('display', 'block');
},
complete: function () {
$('.preloader-bar').css('top','-34px');
$('#loader-ajax').css('display', 'none');
}
});
});
$user['name'] = $_REQUEST['name'];
$user['surname'] = $_REQUEST['surname'];
echo json_encode($user);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question