현재 연락처 양식을 만들고 있으며 스팸을 줄이기 위해 양식에 captcha가 필요합니다. 코드에 captcha를 사용하는 방법에 대한 자습서를 따라 왔지만 잘하면 누군가 여기에서 도울 수 있습니다. 어떤 도움을 주시면 감사하겠습니다.Google 보안 문자 작업에 문제가 발생했습니다.
HTML
<body>
<hgroup>
<h1>Contact Us</h1>
<?php if(isset($_GET['CaptchaPass'])){ ?>
<h3>Your message was sent, you should recieve an email back within 24
hours.</h3>
<?php } ?>
<?php if(isset($_GET['CaptchaFail'])){ ?>
<h3>Captcha Failed. Please try again!</h3>
<?php } ?>
</hgroup>
<form method='post' action='contactver.php'>
<div class="group">
<input type="text" name="name"><span class="highlight"></span><span
class="bar"></span>
<label>Name</label>
</div>
<div class="group">
<input type="email" name="email"><span class="highlight"></span><span
class="bar"></span>
<label>Email</label>
</div>
<div class="group">
<input type="phone" name="phone"><span class="highlight"></span><span
class="bar"></span>
<label>Phone No.</label>
</div>
<div class="group">
<input type="message" name="message"><span class="highlight"></span><span
class="bar"></span>
<label>Message</label>
</div>
<div class="g-recaptcha" data-
sitekey="My Key, want to keep private :)"></div>
<button type="submit" name="login" class="button buttonBlue">Submit Message
<div class="ripples buttonRipples"><span class="ripplesCircle"></span></div>
</button>
</form>
PHP
$firstname = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
if(isset($_POST['login'])) {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = "Want to keep this private :)";
$response = file_get_contents($url."?
secret".$privatekey."&response=".$_POST['g-recaptcha-
response']."&remoteip".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if(isset($data->success) AND $data->success==true) {
echo("Pass");
}else {
header('Location: contact.php?CaptchaFail=true');
echo("Fail");
}
}
PHP에서'? CaptchaPass'로 리다이렉트하는 것을 볼 수 없습니다. – tilz0R
@ tilz0R이 미안하지만 추가하지 않았지만 거기에, 작동하지 않는, 다른 수정 ?? : – Bailee
구글의'$ data' 객체를 검사하지 않는 것이 좋겠습니까? var_dump 또는 print_r을 사용하면 응답을 볼 수 있습니다. – tilz0R