0
votes

So I have created a form below with Zend Framework which I'm then going to customise. My first issue is that with the csrf hash security I get an application error. However, when I remove them lines all I get is a blanks screen which is only resolved when I remove the CPATCHA protection. Can anyone explain to me why?

My Form:

class Application_Form_Clips extends Zend_Form
{

    public function init()
    {

        // Set the method for the display form to POST
        $this->setMethod('post');

        // Add an email element
        $this->addElement('text', 'email', array(
            'label'      => 'Your email address:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'EmailAddress',
            )
        ));

        // Add the comment element
        $this->addElement('textarea', 'comment', array(
            'label'      => 'Please Comment:',
            'required'   => true,
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 20))
                )
        ));

        // Add a captcha
        $this->addElement('captcha', 'captcha', array(
            'label'      => 'Please enter the 5 letters displayed below:',
            'required'   => true,
            'captcha'    => array(
                'captcha' => 'Figlet',
                'wordLen' => 5,
                'timeout' => 300
            )
        ));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Sign Guestbook',
        ));

        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));

    }


}

My Controller:

class AdminController extends Zend_Controller_Action
{

    public function init()
    {

        // get doctrine and the entity manager
        $this->doctrine = Zend_Registry::get('doctrine');
        $this->entityManager = $this->doctrine->getEntityManager();

        // get the users repository
        $this->indexVideos = $this->entityManager->getRepository('\ZC\Entity\Videos');
        $this->indexClips = $this->entityManager->getRepository('\ZC\Entity\Clips');

    }

    public function indexAction()
    {
        // action body
    }

    public function clipsAction()
    {

        // get a form
        $form = new Application_Form_Clips(); 
        $this->view->form = $form;

    }

    public function videosAction()
    {
        // action body
    }


}

My View:

<?php echo $this->form; ?>
1
In php.ini enable display_errors and set error_reporting to E_ALL. Your blank screen will be replaced by an error message telling you why PHP terminated. - drew010

1 Answers

0
votes

Basic error, I hadn't uncommented session.pat in my php.ini