Zend Framework :: Is this code good for user login (Its begining- because that I want to know if its
- by Yosef
Hi,
I new in Zend.
Main Question:
Is this code good for user login (Its beginning- because that I want to know if its can be improve)?
Code understanding question:
Is every time that in action call to his view- code execution in action not going to next row until view request? (I asking about IndexAction that I write down)
Thanks
view index.phtml
<? echo $this->form
controller IndexAction.php
public function indexAction() {
$form=new Application_Form_Login();
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
echo " test value username: ".$form->getValue('username');
}
}
}
form Login.php
public function init() {
$this->setMethod('post');
$this->setName('user login');
$username = new Zend_Form_Element_Text('username');
$username->setLabel("username")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$password = new Zend_Form_Element_Password('password');
$password->setLabel('password')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('submit');
$this->addElements(array($username, $password, $submit));
}