Answer the question
In order to leave comments, you need to log in
Why does it display errors when displaying captcha from google?
Throws an error on page load: The source list for Content Security Policy directive 'script-src' contains an invalid source: ''strict-dynamic''. It will be ignored.
I can not understand the reason, tell me.
<?php
require 'templates/header.php';
define('SITE_KEY', '..........................................');
define('SECRET_KEY', ..........................................');
if($_POST){
function getCaptcha($SecretKey) {
$Response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".SECRET_KEY."&response={$SecretKey}");
$Return = json_decode($Response);
return $Return;
}
$Return = getCaptcha($_POST['g-recaptcha-response']);
var_dump($Return);
if($Return->success == true && $Return->score > 0.5){
echo "Проверка пройдена. Сообщение отправлено!";
} else {
echo "You are Robot";
}
}
?>
<section class="registration main">
<div class="row">
<div class="col-12 reg__ramka">
<div class="row">
<div class="col-6">
</div>
<div class="col-6">
<h3>Регистрация</h3>
<form method="post" id="form_reg" action="/">
<p id="reg_message"></p>
<div id="form_registration">
<ul class="form__reg_ul">
<li>
<label class="form__reg_label">Телефон:</label>
<span class="reg_star">*</span>
<input type="text" name="reg_phone" id="reg_phone">
</li>
<li>
<label class="form__reg_label">e-mail:</label>
<span class="reg_star">*</span>
<input type="text" name="reg_email" id="reg_email">
</li>
<li>
<label class="form__reg_label">Пароль:</label>
<span class="reg_star">*</span>
<input type="text" name="reg_pass" id="reg_pass">
<span id="genpass">cгенерировать</span>
</li>
<li>
<label class="form__reg_label">Имя:</label>
<span class="reg_star">*</span>
<input type="text" name="reg_name" id="reg_name">
</li>
<li>
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response">
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo SITE_KEY;?>"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo SITE_KEY;?>', {action: 'homepage'}).then(function(token) {
// console.log(token);
document.getElementById('g-recaptcha-response').value=token;
});
});
</script>
</li>
</ul>
<div class="form__reg_button">
<button type="submit" name="reg_submit" id="reg_submit">Регистрация <i class="fa fa-chevron-right" aria-hidden="true"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?php
require 'templates/footer.php';
?>
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