我使用谷歌Recaptcha,我已经结束了这段代码。我的目标是让我已经工作的PHP表单仅在验证码完成时才提交。任何帮助,将不胜感激。CAPTCHA整合到现有的PHP表格
<?php
if (isset($_POST['ContactButton'])) {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = "6LePayETAAAAANJze7opnV6bQEX-n02p4UdZ8xfF";
$response = file_get_contents($url . "?
secret=" . $privatekey . "&response" . $_POST['g-recaptcha-
response'] . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
$data = json_decode($respose);
if (isset($data -> success) AND $data -> success == true) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent = " From: $name \n Phone: $phone \n Message: $message";
$recipient = "[email protected]";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: contact-thank-you.html');
exit();
} else {
header('location: index.html?captchafail=True');
}
}
?>
你能解释一下什么是不工作有关它? – thesecretmaster