reCAPTCHAの実装したく下記サイト参考にしたのですが、チェックいれても入れなくても成功してしまいます。 レクチャーいただければ幸いです 参考サイト
reCAPTCHAの実装したく下記サイト参考にしたのですが、チェックいれても入れなくても成功してしまいます。 レクチャーいただければ幸いです 参考サイト https://liapoc.com/recaptcha.html html <form action="post.php" method="post"> <div class="g-recaptcha" data-callback="clearcall" data-sitekey="サイトキー"></div> <input class="submit_button" onclick="location.href='#'" type="submit" value="予約・お問い合わせ" /> </form> <script src='https://www.google.com/recaptcha/api.js'></script> <script type="text/javascript"> function clearcall(code) { if(code !== ""){ $(':submit[name=button]').removeAttr("disabled"); } } </script> php <?php $recaptcha = htmlspecialchars($_POST["g-recaptcha-response"],ENT_QUOTES,'UTF-8'); if(isset($recaptcha)){ $captcha = $recaptcha; }else{ $captcha = ""; echo "captchaエラー"; exit; } $secretKey = "シークレットキー"; $resp = @file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captcha}"); $resp_result = json_decode($resp,true); if(intval($resp_result["success"]) !== 1) { echo '成功'; header('Location: success.html'); }else{ echo '失敗'; header('Location: /'); } ?>
ベストアンサー
>reCAPTCHAの実装したく下記サイト参考にしたのですが、チェックいれても入れなくても成功してしまいます。 記事が間違っているか設計ミスの可能性がありますね。 その場合は、他人のサイトなど参考にせずに、オフィシャルを参照し行えば改善します。
質問者からのお礼コメント
ありがとうございます。
お礼日時:7/5 23:52