Tôi đã theoGoogle reCAPTCHA hiển thị với hình ảnh & Client Side Validation trên Form Gửi
How to Validate Google reCaptcha on Form Submit
tôi có dưới đây mã trong tôi index.php
<!DOCTYPE HTML>
<html>
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form method="post" action="post.php">
<div class="g-recaptcha" data-sitekey="6XXXXXXXXXXXXwdsf0K8HbXXXXXXX"></div>
<input type="submit" value="Submit" />
</form>
</body>
</html>
post.php
$response = $_REQUEST['g-recaptcha-response'];
$secret = '6XXXXXXXXXXXXwdsf0K8HbJNvMw-XXXX';
$server = $_SERVER['REMOTE_ADDR'];
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secret . "&response=" . $response.'&remoteip='.$server);
$response = json_decode($response, true);
if ($response["success"] === true) {
echo "Logged In Successfully";
} else {
echo "You are a robot";
}
exit;
Mã trên đang hoạt động tốt.
Cách xác thực phía khách hàng? Nó không hiển thị hình ảnh xác thực với tùy chọn hình ảnh.
tôi đã được thực hiện dưới đây
tệp post.php của bạn đang thực hiện xác thực bên clinet? – nogad
Nope server side –
wel i dont thực sự biết những gì bạn yêu cầu. – nogad