Probleme mit reCaptcha :(

Hey wollte Heute reCaptcha auf meine Seite intigrieren aber es soll sich nur ein Text hinter dem reCaptcha verstecken.
Also ich möchte nicht, dass irgendwas abgesendet wird.

der code den ich im reCaptcha verstecken will sieht so aus

<?php
$lines = file('text.txt');
echo $lines[array_rand($lines)];
?>

(also wird einfach dann eine random zeile aus dem .txt angezeigt)

dieser Text soll erst erscheinen, wenn dann die reCaptcha prüfung erfolgreich war.

Weiß einer wie ich das anstelle?
 
Nimm den Code aus https://github.com/google/ReCAPTCHA/blob/master/php/example-captcha.php und ersetze die Zeile
PHP:
echo "You got it!";
durch dein Snippet.

Ohne PHP funktioniert es nicht.

danke für die Antwort. Habs versucht, hat aber auch nicht geklappt. Gab nur Fehlermeldungen.

Hier ist mein Code (hab ein paar sachen rausgenommen):

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />


	<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="js/jquery.galleriffic.js"></script>
    
    <script type="text/javascript" src="js/jquery.opacityrollover.js"></script>
    <!-- We only want the thunbnails to display when javascript is disabled -->
    <script type="text/javascript">
    document.write('<style>.noscript { display: none; }</style>');
    </script>


   
</head>

 <span style="font-family:'Courier'; vertical-align: middle">
<div align="center">

<font size="18">











<?php



$lines = file('textfile.txt');

echo $lines[array_rand($lines)];


?>













</font>
</p>
</b>
</span>
<span style="font-family:'Courier'; font-size: 15px; vertical-align: middle">
(refresh for a new account)
</div>
</span>
</div> <!-- end of header -->
</body>
</html>

also um das nochmal klarzustellen.. ich spreche von dem neuen recaptcha mit dem "Are you a Robot?"


& um mich nochmal besser auszudrücken:

Auf meiner Seite soll ein Text durch reCaptcha verborgen werden. Dieser soll dann aber nach bestätigen von reCaptcha einfach erscheinen. Am besten ohne, dass die Seite neu Läd.

(bin ein totaler noob wenn es um sowas geht)

Hoffe du kannst mir irgendwie helfen :(
 
1. Nicht pushen. Wenn jemand eine Antwort hat, dann schreibt er sie dir auch. Es gibt hier nicht so viele Posts, dass man seinen Post wieder an die Spitze pushen müsste.

2. Die Seite muss neu geladen werden, da die Überprüfung der Eingabe nur über PHP erfolgen kann. Die Begründung findest du hinter dem o.g. Link. Auch könntest du sonst möglicherweise schon die Zeilen, die du mit deinem Code einliesst, im voraus auslesen, ohne das Captcha zu lösen.

3. Du musst nur eine Zeile ersetzen, nicht den gesamten Code. Das sieht dann so aus:
PHP:
<?php
/**
 * Sample PHP code to use reCAPTCHA V2.
 *
 * @copyright Copyright (c) 2014, Google Inc.
 * @link      http://www.google.com/recaptcha
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
require_once "recaptchalib.php";
// Register API keys at https://www.google.com/recaptcha/admin
$siteKey = "";
$secret = "";
// reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
$lang = "en";
// The response from reCAPTCHA
$resp = null;
// The error code from reCAPTCHA, if any
$error = null;
$reCaptcha = new ReCaptcha($secret);
// Was there a reCAPTCHA response?
if ($_POST["g-recaptcha-response"]) {
    $resp = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $_POST["g-recaptcha-response"]
    );
}
?>
<html>
  <head><title>reCAPTCHA Example</title></head>
  <body>
     <?php
       if ($resp != null && $resp->success) {
          /** Dein Code **/
          $lines = file('text.txt');
          echo $lines[array_rand($lines)];
       }
     ?>
    <form action="?" method="post">
      <div class="g-recaptcha" data-sitekey="<?php echo $siteKey;?>"></div>
      <script type="text/javascript"
          src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>">
      </script>
      <br/>
      <input type="submit" value="submit" />
    </form>
  </body>
</html>

4. Das Skript erwartet die Datei recaptchalib.php im selben Verzeichnis, siehe Zeile 27 (die erste Codezeile hinter dem Lizenz-Kommentar).

5. Bitte poste immer die kompletten Fehlermeldungen. Ohne die Fehlermeldungen können wir nicht helfen.
 
Zuletzt bearbeitet:
1. Nicht pushen. Wenn jemand eine Antwort hat, dann schreibt er sie dir auch. Es gibt hier nicht so viele Posts, dass man seinen Post wieder an die Spitze pushen müsste.

2. Die Seite muss neu geladen werden, da die Überprüfung der Eingabe nur über PHP erfolgen kann. Die Begründung findest du hinter dem o.g. Link.

3. Du musst nur eine Zeile ersetzen, nicht den gesamten Code. Das sieht dann so aus:
PHP:
<?php
/**
 * Sample PHP code to use reCAPTCHA V2.
 *
 * @copyright Copyright (c) 2014, Google Inc.
 * @link      http://www.google.com/recaptcha
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
require_once "recaptchalib.php";
// Register API keys at https://www.google.com/recaptcha/admin
$siteKey = "";
$secret = "";
// reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
$lang = "en";
// The response from reCAPTCHA
$resp = null;
// The error code from reCAPTCHA, if any
$error = null;
$reCaptcha = new ReCaptcha($secret);
// Was there a reCAPTCHA response?
if ($_POST["g-recaptcha-response"]) {
    $resp = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $_POST["g-recaptcha-response"]
    );
}
?>
<html>
  <head><title>reCAPTCHA Example</title></head>
  <body>
     <?php
       if ($resp != null && $resp->success) {
          /** Dein Code **/
          $lines = file('text.txt');
          echo $lines[array_rand($lines)];
       }
     ?>
    <form action="?" method="post">
      <div class="g-recaptcha" data-sitekey="<?php echo $siteKey;?>"></div>
      <script type="text/javascript"
          src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>">
      </script>
      <br/>
      <input type="submit" value="submit" />
    </form>
  </body>
</html>

4. Das Skript erwartet die Datei recaptchalib.php im selben Verzeichnis, siehe Zeile 27.

5. Bitte poste immer die kompletten Fehlermeldungen. Ohne die Fehlermeldungen können wir nicht helfen.


Hey danke! Jetzt habe ich das Problem, dass jetzt unter dem Text, weil es sich ja um die selbe Seite handelt immer noch die reCaptcha Box ist, obwohl der Text ja angezeigt wird. Kann ich die dann verbergen?
 
Hey danke! Jetzt habe ich das Problem, dass jetzt unter dem Text, weil es sich ja um die selbe Seite handelt immer noch die reCaptcha Box ist, obwohl der Text ja angezeigt wird. Kann ich die dann verbergen?

... ähm.. mit einer simplen else-Bedingung nach der Überprüfung des Parameters? Also z.B. so (nur <body>-Inhalt!):

PHP:
    <?php 
       if ($resp != null && $resp->success) { 
          /** Dein Code **/ 
          $lines = file('text.txt'); 
          echo $lines[array_rand($lines)]; 
       } else {
    ?> 
    <form action="?" method="post"> 
      <div class="g-recaptcha" data-sitekey="<?php echo $siteKey;?>"></div> 
      <script type="text/javascript" 
          src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>"> 
      </script> 
      <br/> 
      <input type="submit" value="submit" /> 
    </form> 
    <?php 
       }
    ?>
 
Zurück
Oben