Why does my PHP reCAPTCHA only display on Chrome and Safari?

匆匆过客 提交于 2019-12-11 19:00:48

问题


I'm using the PHP reCAPTCHA on my company's website. I basically just followed this tutorial https://developers.google.com/recaptcha/docs/php which is pretty straightforward. Anyway, everything displays and submits fine on Chrome and Safari, but on IE10 and Firefox the reCAPTCHA box simply doesn't show up client-side. I somewhat diverge from the tutorial in the way that I don't have a separate verification page, but I still don't see how this would affect the image displaying on various browsers. Any suggestions?

<?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
}
?>

回答1:


Google Chrome likes to auto correct bad HTML syntax. Make sure your recaptcha_get_html() function returns proper HTML code. What is the recaptcha_get_html function?

Does the source code contain any reCaptcha stuff, or is it entirely missing?

Do you have an example of the web page somewhere live?

Sorry this is marked as an answer, I can not comment on posts still?



来源:https://stackoverflow.com/questions/24335705/why-does-my-php-recaptcha-only-display-on-chrome-and-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!