-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
45 lines (37 loc) · 846 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once 'recaptcha.class.php';
$form_id = "form";
$site_key = 'YOUR_SITE_KEY';
$secret_key = 'YOUR_SECRET_KEY';
$recaptcha = new Recaptcha($form_id, $site_key, $secret_key);
?>
<!doctype html>
<html>
<head>
<title>ReCAPTCHA v3 API Class Demo</title>
</head>
<body>
<?php ob_start(); ?>
<form id="form" method="post">
<input type="text" name="example" value="" placeholder="Example Field" />
<?php echo $recaptcha->button(); ?>
</form>
<?php
$form = ob_get_clean();
if(!empty($_POST)) {
$response = $recaptcha->get_response();
echo "Success: ". ( $response->success ? 'true' : 'false' ) ."<br />\r\n";
echo "Score: ". $response->score ."<br />\r\n";
if($response->success) {
echo "Passed Captcha.";
} else {
echo "Failed Captcha.";
echo $form;
}
} else {
echo $form;
}
echo $recaptcha->script();
?>
</body>
</html>