Authenstification avec Zend framework
Bonjour ,je ss nouvelle en PHP ,et je voulai faire une authentification mais j'ai l'erreur suivante :
Citation:
Notice: Undefined index: in C:\wamp\www\dexiemeProjetZend\library\Zend\Form.php on line 1017 Fatal error: Call to a member function getOrder() on a non-object in C:\wamp\www\dexiemeProjetZend\library\Zend\Form.php on line 1017
voici mon code pour la Form:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
class Form_LoginForm extends Zend_Form{
public function __construct($options = null){
parent::__construct($options);
$this->setName('Login');
$username=new Zend_Form_Element_Text('username');
$username->setLabel('Login ')
->setRequired();
$password=new Zend_Form_Element_Password('password');
$password->setLabel('Password ')
->setRequired(true);
$login=new Zend_Form_Element_Submit('login');
$login->setLabel('Connexion ');
$this->addElement(array($username,$password,$login));
$this->setMethod('post');
$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl(),'/auth/login');
}
}?> |
ET voici mon code controller:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public function loginAction()
{
if(Zend_Auth::getInstance()->hasIdentity()){
$this->_redirect('index/index');
}
$request =$this->getRequest();
$form = new Form_LoginForm();
if($request->isPost())
{
if($form->isValid($this->_request->getPost())){
$authAdapter =$this->getAuthAdapter();
$username=$form->getValue('username');
$password=$form->getValue('password');
$authAdapter->setIdentity($username)
->setCredential($password);
$auth =Zend_Auth::getInstance();
$result= $auth->authenticate($authAdapter);
if($result->isValid())
{
$identity = $authAdapter-> getResultRowObject();
$authStorage = $auth-> getStorage();
$authStorage->write($identity);
$this->_redirect('index/index');
}else
{
$this->view->errorMessage="login ou mot de passe invalide";
}
}
}
$this->view->form = $form;
} |
Veuillez m'aidez SVP ,le plus vite possible