开发者

install reCaptcha and white page

开发者 https://www.devze.com 2023-02-26 04:41 出处:网络
I\'ve downloaded librecaptcha.php and made test.php: <?php require_once(\'recaptchalib.php\'); $publickey = \"MY_KEY\"; // you got this from the signup page

I've downloaded librecaptcha.php and made test.php:

<?php
require_once('recaptchalib.php');
$publickey = "MY_KEY"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>

But it shows white screen. Problem is in require_once(), because if I exit with echo before require_once() - it echoes to page, but if after require - doesn't echo.

File recaptchalib.php is in the same folder as the test.php

What it can be?

UPD 1:

I think, the problem is in require_once('recaptchalib.php'). No matter what code is after it, white screen will apear. For example:

<?php
require_once('recaptchalib.php');
exit('test_after');
?>

This file return white screen. But this script works:

<?php
exit('test_before');
require_once('recaptchalib.php');
?>

So,开发者_如何学Go the problem is in lib file itself. Path is correct, and I haven't modified the file.

UPD2:

So, I should to check recaptchalib.php file. I've create lib.php file with such content:

<?php 
echo "lib"; 
?> 

It've been opened in all browsers. But then I've added (copy-pasted) the content of recaptchalib.php before echo "lib". So it looks like:

<?php
/* recaptchalib.php content*/
echo "lib";
?>

And I've seen blank screen in FF, 500 server internal error in Chrome and Remove server or file not found on Opera.

UPD3:

recaptchalib.php began to work only when I've copied it's content function-by-function in a new file. (when I copied whole content - it hasn't work). I don't understand why??


No it's not problem in library!

Your test script will work in Safari but will not work in Firefox! (I don't know for rest of them because I use just these)

Have you tried to check it in more than one browser?

According to official documentation: Using reCAPTCHA with PHP you have to put PHP code on HTML page.

The body tag is required or the CAPTCHA may not show on some browsers

So you have to create HTML page and it will work

  <html>
    <body>
      <!-- your HTML content -->

      <form method="post" action="submit_recaptcha.php">
        <?php
          require_once('recaptchalib.php');
          $publickey = "your_public_key"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>
        <input type="submit" />
      </form>

      <!-- more of your HTML content -->
    </body>
  </html>
  • Here's my test (works in all browsers)!
  • Here's your code on my server (it doesn't work in FF, but works in Safari)

Update:

Also double check is your domain on reCaptcha page same as one where you use your code.

Example:

install reCaptcha and white page

This is exact copy of my working example from server (removed Public Key)! This is what I have here http://service-kl.com/code/recaptcha/

Give it a try, but before that, you have to replace public key in index.php with your own.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号