teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

誤字

2019/09/06 07:09

投稿

konoha0708
konoha0708

スコア36

title CHANGED
File without changes
body CHANGED
@@ -74,5 +74,5 @@
74
74
  ```
75
75
 
76
76
  ※階層は、contact/index.html ←お問い合わせフォーム
77
- contact/index.html/mailformpro/config.cgi ←サーバー側の設定を行ったファイル
77
+ contact/mailformpro/config.cgi ←サーバー側の設定を行ったファイル
78
78
  となっています。

1

追加情報の掲載

2019/09/06 07:09

投稿

konoha0708
konoha0708

スコア36

title CHANGED
File without changes
body CHANGED
@@ -21,4 +21,58 @@
21
21
  ちなみにPHPファイルを設置してみると、下記のエラーが出てしまいます。
22
22
 
23
23
  「サイト所有者のエラー
24
- サイトキーのドメインが無効」
24
+ サイトキーのドメインが無効」
25
+
26
+
27
+
28
+
29
+ ********追記***************
30
+
31
+ お問い合わせフォームのhtmlファイルの<head>内に下記を追記
32
+ ```ここに言語を入力
33
+ <script src="https://www.google.com/recaptcha/api.js"></script>
34
+ ```
35
+ 上記と同じ、お問い合わせフォームのhtmlファイルの送信ボタンの前の行に下記を追記
36
+
37
+ ```ここに言語を入力
38
+ <div class="g-recaptcha" data-sitekey="[****************]"></div>
39
+ ```
40
+
41
+ mailformpro/config.cgi に
42
+
43
+ ```ここに言語を入力
44
+ #!/usr/bin/perl
45
+
46
+ use strict;
47
+ use CGI;
48
+ use LWP::UserAgent;
49
+ use JSON::Parse;
50
+
51
+ my $secret_key = '[*************************]';
52
+ my $url = 'https://www.google.com/recaptcha/api/siteverify';
53
+
54
+ my $cgi = CGI->new();
55
+ my $ua = LWP::UserAgent->new();
56
+ my $recaptcha_response = $cgi->param('g-recaptcha-response');
57
+ my $remote_ip = $ENV{REMOTE_ADDR};
58
+ my $response = $ua->post(
59
+ $url,
60
+ {
61
+ remoteip => $remote_ip,
62
+ response => $recaptcha_response,
63
+ secret => $secret_key,
64
+ },
65
+ );
66
+ if ( $response->is_success() ) {
67
+ my $json = $response->decoded_content();
68
+ my $out = parse_json($json);
69
+ if ( $out->{success} ) {
70
+ # 正常処理
71
+ }
72
+ }
73
+
74
+ ```
75
+
76
+ ※階層は、contact/index.html ←お問い合わせフォーム
77
+ contact/index.html/mailformpro/config.cgi ←サーバー側の設定を行ったファイル
78
+ となっています。