Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Pages: 1
Bonjour,
Après de nombreuses recherches infructueuses, je m'adresse à vous.
Je souhaite mettre en place un captcha sur un formulaire, et malgré le fait que ça a l'air simple sur ce que j'ai lu, pas moyen d'obtenir le moindre résultat.
En ajoutant ceci dans mon formulaire, celui ce ne s'affiche plus... :
$this->addElement('captcha', 'captcha', array( 'label' => 'Please enter the 5 letters displayed below:', 'required' => true, 'captcha' => array( 'captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 300 ) ));
J'ai essayé pas mal d'autres choses, avec toujours le même problème, mon formulaire n'apparait plus.
En espérant trouver la solution...
@+
Dernière modification par timautin (02-06-2010 17:35:01)
Hors ligne
Ce code :
<?php require_once 'Zend/Form.php'; require_once 'Zend/View.php'; $form = new Zend_Form(); $view = new Zend_View(); $form->setView($view); $form->addElement('captcha', 'captcha', array( 'label' => 'Please enter the 5 letters displayed below:', 'required' => true, 'captcha' => array( 'captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 300 ) )); echo $form->__toString();
fonctionne très bien chez moi et affiche :
<form enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form"> <dt id="captcha-label"><label for="captcha-input" class="required">Please enter the 5 letters displayed below:</label></dt> <dd> <pre> _ _ ______ _ __ ______ __ __ | | | || /_ _// | |/ // /_ _// \ \\ / // | |/\| || -| ||- | ' // -| ||- \ \/ // | /\ || _| ||_ | . \\ _| ||_ \ // |_// \_|| /_____// |_|\_\\ /_____// \// `-` `-` `-----` `-` --` `-----` ` </pre> <input type="hidden" name="captcha[id]" value="ed23885c3b9c6963a1d7534be3655bed" id="captcha-id"> <input type="text" name="captcha[input]" id="captcha-input" value=""></dd></dl></form>
Affiches-tu bien les erreurs PHP ? Que dit le log PHP ?
Hors ligne
Et bien ton code ne m'affiche rien, mais en regardant le log, il est loin d'être vide . Je pensais pourtant bien afficher les erreurs avec ça dans mon index.php :
error_reporting(E_ALL|E_STRICT); ini_set('display_errors', 1);
Mais visiblement ce n'est pas le cas.
J'ai ça dans le log :
[02-Jun-2010 07:49:54] PHP Warning: include_once(FrontController.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Loader.php on line 146 [02-Jun-2010 07:49:54] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening 'FrontController.php' for inclusion (include_path='/Applications/MAMP/htdocs/LPO_Vendee/application/../library:/Applications/MAMP/htdocs/LPO_Vendee/library:.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Loader.php on line 146 [02-Jun-2010 07:49:54] PHP Warning: include_once(FrontController.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Loader.php on line 146 [02-Jun-2010 07:49:54] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening 'FrontController.php' for inclusion (include_path='/Applications/MAMP/htdocs/LPO_Vendee/application/modules/admin/models:/Applications/MAMP/htdocs/LPO_Vendee/application/../library:/Applications/MAMP/htdocs/LPO_Vendee/library:.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Loader.php on line 146 [02-Jun-2010 07:49:54] PHP Warning: Exception caught by form: session has already been started by session.auto-start or session_start() Stack Trace: #0 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Session/Namespace.php(143): Zend_Session::start(true) #1 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Captcha/Word.php(245): Zend_Session_Namespace->__construct('Zend_Form_Captc...') #2 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Captcha/Word.php(289): Zend_Captcha_Word->getSession() #3 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Captcha/Word.php(334): Zend_Captcha_Word->_setWord('sohej') #4 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Captcha/Figlet.php(69): Zend_Captcha_Word->generate() #5 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Form/Element/Captcha.php(193): Zend_Captcha_Figlet->generate() #6 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Form/Decorator/FormElements.php(101): Zend_Form_Element_Captcha->render() #7 /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Form.php(2672): Zend_Form_Decorator_FormElemen in /Applications/MAMP/htdocs/LPO_Vendee/library/Zend/Form.php on line 2692 [02-Jun-2010 07:49:54] PHP Notice: Undefined variable: cout in /Applications/MAMP/htdocs/LPO_Vendee/application/modules/default/views/scripts/sorties/index.phtml on line 136 [02-Jun-2010 07:49:54] PHP Notice: Undefined index: connecte in /Applications/MAMP/htdocs/LPO_Vendee/application/modules/default/views/scripts/sorties/index.phtml on line 221 [02-Jun-2010 07:49:54] PHP Notice: Undefined variable: cout in /Applications/MAMP/htdocs/LPO_Vendee/application/modules/default/views/scripts/sorties/index.phtml on line 136 [02-Jun-2010 07:49:54] PHP Notice: Undefined index: connecte in /Applications/MAMP/htdocs/LPO_Vendee/application/modules/default/views/scripts/sorties/index.phtml on line 221
:s
Le problème semble venir des sessions. Je m'en sers en effet sur la page en question, ça pose un problème avec les captchas ??
Merci d'être passé, et désolé pour le double post, y a t-il moyen de supprimer l'autre ?
A+
EDIT : en effet en virant le session_start() ça marche. Sauf que j'en ai besoin :s ! J'imagine que zend a un module pour gérer les sessions que je vais devoir utiliser (c'est ma 1ère appli zend), je vais me renseigner de ce côté là. Mais c'est bête c'est plutôt simple à utiliser les sessions
Dernière modification par timautin (02-06-2010 09:59:31)
Hors ligne
Oui il faut mieux utiliser les sessions de zend :
http://framework.zend.com/manual/fr/zend.session.html
Hors ligne
Merci pour le lien
Hors ligne
Pages: 1