Je fais un tableau pour le captcha et j'offre la possibilite de renouveler le captcha:
<?php
include 'captchaList.php';
?>
<li class="captcha">
<label for="captcha">Captcha "<b><font color="blue">
<span class="CaptchaReload"><?php echo $captcha_display; ?></span>
</font></b>"</label>
<input type="text" name="captcha" size="25" maxlength="30" class="captcha" />
<img src="refresh.png" width="24" height="24" align="absmiddle" class="CaptchaReload" style="cursor: pointer" />
<span class="CaptchaError"></span>
</li>
captchaList.php<?php
$captcha_array = array('un', 'deux', 'trois', 'quatre', 'cinq');
$captcha_display = $captcha_array[rand(0, count($captcha_array)-1)];
$_SESSION['captcha_display'] = $captcha_display;
?>
au clique sur l'image refresh je produit une operation de changement de captcha:$('img.CaptchaReload').click(function(){
$.ajax({
type: "POST",
url: "captchaCheck.php",
success: function(data) {
$('span.CaptchaReload').show().html(data);
} // end function
}); // end Ajax
}); // end click function
captchaCheck.php:<?php
include 'captchaList.php';
echo $captcha_display;
?>
quand je clique pour changer le mot de captcha, par exemple au debut il y ait "un", ca recharge et ca donne "cinq", j'ecris "cinq" mais je me trouve qu'il a toujours en memoire "un", c'est quoi le probleme sur mon code.merci