【发布时间】:2022-05-09 22:57:56
【问题描述】:
我在我公司的网站上使用 PHP reCAPTCHA。我基本上只是按照这个教程https://developers.google.com/recaptcha/docs/php 这很简单。无论如何,一切在 Chrome 和 Safari 上都可以正常显示和提交,但在 IE10 和 Firefox 上,reCAPTCHA 框根本不会出现在客户端。我与教程有些不同,因为我没有单独的验证页面,但我仍然看不出这会如何影响各种浏览器上显示的图像。有什么建议吗?
<?php
$page = "visit";
include 'layout/topnav.php';
?>
<script language="JavaScript">
function formValidate() {
if (document.data.Comments.value == "") { alert("Please include a quick question"); return false; }
else if (document.data.Email.value == "") { alert("Please include your email."); return false; }
else return true;
}
</script>
<?php
$Added = False;
if (isset($_POST['submit1'])){
require_once('recaptchalib.php');
$privatekey = "xxxxx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo "Your CAPTCHA response was not accepted. Please try again. See the Help button to the right of the entry field to learn more.";
$Email=$_POST['Email'];
$Comments=$_POST['Comments'];
$Added = False;
}
else {
// Your code here to handle a successful verification
/* Add to Database */
$Email = '';
$Comments = '';
$Added = True;
}
}
if(!$Added)
{
?>
<html>
<head>
<body> <!-- the body tag is required or the CAPTCHA may not show on some browsers -->
<form method="post" action="quick_question.php" name="data" onsubmit="return formValidate()">
<b>Your Quick Question:<font color="red">*</font></b><br />
<textarea wrap="hard" name="Comments" rows="5" cols="55" id="question" class="inputBox" ><? echo $Comments?></textarea>
<table cellpadding="0">
<tr>
<td width="40%" valign="top"><b>Your E-mail:<font color="red">*</font></b></td>
</tr>
<tr>
<td><input type="text" name="Email" size="10" id="email" class="inputBox" value="<? echo $Email?>"/></td>
</tr>
<tr><td>
<b>CAPTCHA Verification:</b><font color="red">*</font>
</td></tr>
<tr><td>
<?php
require_once('recaptchalib.php');
$publickey = "yyyy"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</td></tr>
<tr><td id="submit">
<input type="submit" name="submit1" />
</td></tr>
</table>
</form>
</body>
</html>
<?php
}
?>
【问题讨论】:
标签: php html cross-browser recaptcha