Zend Framework :: Is this code good for user login (Its begining- because that I want to know if its
Posted
by Yosef
on Stack Overflow
See other posts from Stack Overflow
or by Yosef
Published on 2010-06-12T18:48:38Z
Indexed on
2010/06/12
18:52 UTC
Read the original article
Hit count: 206
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));
}
© Stack Overflow or respective owner