[RESOLU] Intégration d'un Captcha .

Petit nouveau ! | 2 Messages

13 août 2012, 22:18

Bonsoir à tous

Voilà je cherche à intégrer un nouveau captcha dans mon site Web au lieu du recpatcha , mais je n'y arrive pas .

Voici un exemple d'intégration du nouveau captcha , il fonctionne parfaitement .
<form method='post'>
<?php require_once('captcha-lib.php'); 
$publicKey = "XXX"; 
$privateKey = "XXX"; 
$authenKey = "XXX"; 

# Reponse des services du captcha
$response = null; 
# Code erreur 
$error = null; 

if (isset($_POST["captcha_response_field"])) { 
$remoteIp = $_SERVER['REMOTE_ADDR']; 
# Controle du captcha 
$response = captcha_verify ($privateKey, $_POST["captcha_challenge_field"], $_POST["captcha_response_field"], $remoteIp, $authenKey); 


if ($response->is_valid) { 
echo "Valid captcha answer!"; 
} else { 
$error = $response->error; 
} 
}

 # Affichage du captcha 
 echo captcha_generate_html($publicKey, $error); 
 ?> 
 
 <div><input type="submit" value="submit"/></div> 
 </form>

Maintenant je voudrais si le captcha est saisi correctement que l'utilisateur soit redirigé vers SHOWLINKS pour voir les liens sinon un message d'erreur apparait ...

La page du "CAPTCHAFORM " du recaptcha était comme ca :


<form name='linkprotect' action='showlinks.php' method='POST' enctype='application/x-www-form-urlencoded' >      
                                <div class="links_form">
                                    <div class="form1">                                    
                                        <h2></h2>
 <?php
require_once('captcha/recaptchalib.php');
// $publickey = "XXX";
 echo recaptcha_get_html($publickey);
    ?>

                                    </div>
                                     <div class="form1">                                    
                                       
                                       <input type="hidden" name="linkid" value="<?php echo $linkid; ?>"> 
                                       
       
                                   </div>
                                             </div>
                                             
                                    <div class="captcha"><input type="image" src="images/viewlinks.png" id="Protect" /></div>
                                </div>

                                  </form> 
                             
Comment je peux intégrer le nouveau captcha ?

Merci à vous .

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 8758 Messages

14 août 2012, 00:49

salut


as tu compris cette partie ?
<?php

if ($response->is_valid) {
echo "Valid captcha answer!";
} else {
$error = $response->error;
} 
?>
@+
Il en faut peu pour être heureux ......

Petit nouveau ! | 2 Messages

14 août 2012, 01:37

Salut
C'est l'action showlinks qui pose problème .
J'ai tenté ce code mais quand l'utilisateur click sur le bouton , il est redirigé vers le lien SHOWLINKS.php même s'il ne tape pas le captcha ou qu'il tape un captcha erroné ...
Comment faire pour le redirigé vers l'action "SHOWLINKS" uniquement s'il tape le captcha correctement .

<form name='linkprotect' action='showlinks.php' method='POST'  >   

<?php require_once('captcha-lib.php');
$publicKey = "XXX";
$privateKey = "XXX";
$authenKey = "XXX";

# Reponse des services du captcha
$response = null;
# Code erreur
$error = null;

if (isset($_POST["captcha_response_field"])) {
$remoteIp = $_SERVER['REMOTE_ADDR'];
# Controle du captcha
$response = captcha_verify ($privateKey, $_POST["captcha_challenge_field"], $_POST["captcha_response_field"], $remoteIp, $authenKey);


if ($response->is_valid) {
echo "Valid captcha answer!";
} else {
$error = $response->error;
}
}

 # Affichage du captcha
 echo captcha_generate_html($publicKey, $error);
 ?>
 
 <div><input type="submit" value="submit"/></div>
 </form>

                      

ViPHP
xTG
ViPHP | 7331 Messages

14 août 2012, 06:46

Visiblement la réponse à la question de moogli est un non...
Le formulaire doit être envoyé vers une page vérifiant le captcha.
Dans ton cas c'est la même page.
Et le résultat de la verif vrai ou faux c'est la condition montrée par moogli, qui est donc à compléter pour ajouter une redirection.