-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-captcha.php
37 lines (32 loc) · 960 Bytes
/
example-captcha.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
<html>
<body>
<form action="" method="post">
<?php
require_once ("Recaptcha.php");
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "";
$privatekey = "";
$recaptcha = new Recaptcha($publickey, $privatekey);
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = $recaptcha->check_answer($_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
echo $recaptcha->get_html($error);
?>
<br/>
<input type="submit" value="submit" />
</form>
</body>
</html>