質問編集履歴
4
コード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,6 +23,16 @@
|
|
23
23
|
<input type="hidden" name="recaptchaResponse" id="recaptchaResponse" />
|
24
24
|
<button type="submit">submit</button>
|
25
25
|
</form>
|
26
|
+
|
27
|
+
<script src="https://www.google.com/recaptcha/api.js?render='reCAPTCHA_site_key'"></script>
|
28
|
+
<script>
|
29
|
+
grecaptcha.ready(function() {
|
30
|
+
grecaptcha.execute('reCAPTCHA_site_key').then(function(token) {
|
31
|
+
var recaptchaResponse = document.getElementById('recaptchaResponse');
|
32
|
+
recaptchaResponse.value = token;
|
33
|
+
});
|
34
|
+
});
|
35
|
+
</script>
|
26
36
|
```
|
27
37
|
|
28
38
|
```php
|
3
コード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,7 +19,10 @@
|
|
19
19
|
### 参考を見ながら書いてみたソースコード
|
20
20
|
|
21
21
|
```html
|
22
|
+
<form action="test.php" method="post" name="form">
|
22
23
|
<input type="hidden" name="recaptchaResponse" id="recaptchaResponse" />
|
24
|
+
<button type="submit">submit</button>
|
25
|
+
</form>
|
23
26
|
```
|
24
27
|
|
25
28
|
```php
|
2
エラー表示の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,5 +44,8 @@
|
|
44
44
|
|
45
45
|
### 試したこと
|
46
46
|
|
47
|
+
上記のコードでは
|
48
|
+
Warning: count(): Parameter must be an array or an object that implements Countable in...
|
49
|
+
とエラーが出ました。
|
47
|
-
|
50
|
+
あとタイムアウトエラーが回避できませんでした。
|
48
51
|
あと人間の処理を2回書かなくていい方法があればそれも教えていただきたいです。
|
1
間違い修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
// 人間の処理
|
35
35
|
}
|
36
36
|
else{
|
37
|
-
$error = $
|
37
|
+
$error = $reCAPTCHA->{'error-codes'};
|
38
38
|
if( count($error) == 1 && $error[0] == 'timeout-or-duplicate' ){
|
39
39
|
// 人間の処理
|
40
40
|
}
|