-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_v2.php
More file actions
52 lines (46 loc) · 1.36 KB
/
demo_v2.php
File metadata and controls
52 lines (46 loc) · 1.36 KB
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
46
47
48
49
50
51
52
<?php
require_once('config.php');
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title> reCAPTCHA V2 demo </title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var siteVerifyCallback = function(response) {
document.getElementById("token").value = response;
};
var onloadCallback = function() {
grecaptcha.render('html_element', {
'sitekey' : '<?=RECAPTCHA_V2_SITE_KEY?>',
'callback' : siteVerifyCallback
});
};
function onSubmit() {
var token = document.getElementById("token").value;
if(token==''){
return false;
}
$.get("verify_v2.php",{token:token})
.done(function(data){
if(data.success==true){
alert('v2 verify success');
}else{
alert('v2 verify fail errors:' + data.errors);
}
});
}
</script>
</head>
<body>
<form action="?" method="POST" onsubmit="return false">
<div id="html_element"></div>
<br>
token: <input type="text" id="token" value="">
<input type="submit" value="Submit" onClick="onSubmit()">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
</body>
</html>