这是我第一次在stackoverflow上发帖。我是设计师自学HTML5,CSS,Javascript& PHP。我对Javascript& amp; PHP在HTML5和HTML中有更多经验CSS。 我一直在研究我的问题并尝试解决这个问题几个星期(当时间可用时)并且不断出现。这是我的问题:
我一直在使用两种表格的网站。我去了reCAPTCHA抢了我的公共&私钥并将它们添加到我的网站,我的reCAPTCHA显示在网站上。
目前,有人可以正确(或不正确)输入reCAPTHCA,表单仍会提交。这只是因为我删除了验证php文件中的else {}代码,见下文。当我添加else {}代码时,表单将在提交时死亡并给我" reCAPTCHA输入错误。回去再试一次。(reCAPTCHA说:wrong-captcha-sol)"。下面的代码直接放在我的开头< ?php tag。
require_once('recaptchalib.php');
$privatekey = "myprivatekey_removed";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA was entered incorrectly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// my code
}
最终,有人知道为什么我的代码没有验证,即使我已根据我找到并能够遵循的每个教程正确输入了所有内容。我试过进入< ?php require_once? >代码序列作为<的直接子代。形式>以及我表格中的其他所有内容。我还没有加入< ?php require_once? >并最终获得相同的结果。
<form method="post" action="paperclip.php" name="submission" id="contactform" class="form c-form">
<?php
require_once('recaptchalib.php');
$publickey = "6LffWgATAAAAAEfZ6Q0bo57UUz5MwbA3T9dl_uWn";
echo recaptcha_get_html($publickey);
?>
<fieldset>
<input name="name" type="text" id="name" placeholder="Your Name" />
<input name="email" type="text" id="email" placeholder="Your E-Mail" />
<textarea name="comments" id="comments" placeholder="If you are submitting an entry for the Paperclip Contest, you must include the ad name and page that the paperclip appears."></textarea>
<div class="six col">
<div style="float: right;" class="g-recaptcha" data-sitekey="6LffWgATAAAAAEfZ6Q0bo57UUz5MwbA3T9dl_uWn">
</div>
</div>
<div class="six col">
<div class="text-align: center">
<input type="submit" class="submit btn color" id="submit" value="Send message" />
</div>
</div>
</fieldset>
</form>
我也有javascript行:
<script src='https://www.google.com/recaptcha/api.js'></script>
在我的&lt;头&gt;我的html文件。
在PHP验证代码之后,这听起来像我的PHP代码中的错误吗?如果是这样,请告诉我,我可以发布剩余的PHP文件。
非常感谢任何帮助,我会尽力帮助处理任何请求。