我正在尝试将验证码添加到我的网站,并且我试图感谢您在不同的页面中打开而不是在同一文件中使用php,我该怎么做呢?
据我所知,这是围绕表单的php部分,但我不知道如何更改它以发送到单独的感谢页面。
编辑 - 如果我添加一个操作页面,验证码会中断,但表单会提交,当我执行操作时,验证码有效,但不提交
<!DOCTYPE html>
<?php
// grab recaptcha library
require_once "recaptchalib.php";
// your secret key
$secret = "MY SECRET KEY";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
?>
<html lang="en">
<head>
<!--js-->
<script src='https://www.google.com/recaptcha/api.js'></script>
<title>MATA captcha test</title>
</head>
<body>
<?php
if ($response != null && $response->success) {
echo "Hi " . $_POST["name"] . " (" . $_POST["email"] . "), thanks for submitting the form!";
} else {
?>
<form action="" method="post">
<label for="name">Name:</label>
<input name="name" required><br />
<label for="email">Email:</label>
<input name="email" type="email" required><br />
<div class="g-recaptcha" data-sitekey="MY KEY"></div>
<input type="submit" value="Submit" />
</form>
<?php } ?>
</body>
</html>
答案 0 :(得分:0)
这是你的意思吗?
<form action="insert_your_site_here.php" method="post">
而不是
<form action="" method="post">