<?php class UwierzytelnienieController extends Zend_Controller_Action { public function init() { } public function indexAction() { } public function loginAction() { if(Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('index/index'); } $zadanie = $this->getRequest(); $form = new Form_LogForm(); if($zadanie->isPost()){ if($form->isValid($this->_request->getPost())) { $uwierzAdapter = $this->pobierzUwierzAdapter(); $ope_login = $form->getValue('ope_login'); $ope_haslo = $form->getValue('ope_haslo'); $uwierzAdapter->setIdentity($ope_login) ->setCredential($ope_haslo); $uwierzytelnienie = Zend_Auth::getInstance(); $wynik = $uwierzytelnienie->authenticate($uwierzAdapter); //uwierzytelnienie if($wynik->isValid()){ $identyfikacja = $uwierzAdapter->GetResultRowObject(); $uwierzMagazyn = $uwierzytelnienie->getStorage(); //getStorage(); $uwierzMagazyn ->write($identyfikacja); $this->_redirect('index/index'); } else { $this->view->komunikatBledu = 'Błąd logowania!'; } } } $this->view->form = $form; } public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); $this->_redirect('index/index'); } private function pobierzUwierzAdapter() { $uwierzAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter()); $uwierzAdapter->setTableName('sys_operatorzy') ->setIdentityColumn('ope_login') ->setCredentialColumn('ope_haslo'); return $uwierzAdapter; } }
class Form_LogForm extends Zend_Form { public function __construct($option = null) { parent::_construct($option); $this->setName('login'); $ope_login = new Zend_Form_Element_Text('ope_login'); $ope_login->setLabel('Operator') ->setRequired(); $ope_haslo = new Zend_Form_Element_Password('ope_haslo'); $ope_haslo->setLabel('Hasło') ->setRequired(true); $login = new Zend_Form_Element_Submit('login'); $login -> setLabel('Login'); $this->setMethod('post'); $this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl().'index/index'); } }
gdy zarymuje 18 linijkę i 44 linijkę
a zamiast
$ope_login = $form->getValue('ope_login'); $ope_haslo = $form->getValue('ope_haslo');
wprowadze
$ope_login = 'admin' $ope_haslo = 'admin'
WSZYSTKO DZIAŁA!
natomiast w tej postaci wyświetla mi błąd
Fatal error: Class 'Form_LogForm' not found in C:\wamp\www\srodki\application\controllers\UwierzytelnienieController.php on line 18
Struktura jest taka
application->forms->LogForm.php
application->controllers->UwierzytelnienieController.php
Bardzo proszę o pomoc, siedze nad tym od 13.00 i nic nie moge wykombinować, pewnie jakieś trywialne przeoczenie ....