<?php
//initialise le captcha
$captcha = new Zend_Captcha_Image(array(
'font' => realpath('images/fonts_defaut/arial.ttf'),
'ImgDir' => realpath('images/captcha'),
'WordLen' => 3,
'Width' => 100,
'dotNoiseLevel' => 40,
'lineNoiseLevel'=> 3,
'ImgAlt' => 'Captcha'
));
//si une insertion demandée
if(!empty($_POST['ajouterComment'])){
//vérifie la validité du captcha entrée
if ($captcha->isValid($_POST['captcha'])) {
$captcha_ok=true;
//faire l'insertion
//redirigé vers la page d'affichage
header("HTTP/1.0 302 Found");
header('Location: /Index:'.$_POST['id_news']);
}else{
$captcha_ok=false;
}
//générer l'image
$captcha_id = $captcha->generate();
}
?>
//le formulaire ici
//afficher l'image
<?php echo $captcha->render(new Zend_View());?>
//demander le résultat
<input id="captcha" type="text" name="captcha[input]" />
//envoyer en cacher la session d'image générer
<input type="hidden" name="captcha[id]" value="<?php echo $captcha_id;?>" />
//afficher une erreur si le mauvais captcha à été entrée
<?php if(!$captcha_ok) echo "Erreur de Captcha";?>
Site de Eru r199
by Benoît Guillaume est mis à disposition selon les termes de la licence Creative Commons Paternité-Pas d'Utilisation Commerciale-Partage des Conditions Initiales à l'Identique 2.0 France.
Mise en page © 2008
Elephorm et
Alsacréations
exécution en 506 millisecondes