parse error, expecting `T_FUNCTION'
Bonjour,
Je veux créer une page d'authentification avec la classe Zend_Auth_Adapter_DbTable et voila ce qui m'a affiché durant l'éxecution:
Citation:
Parse error: parse error, expecting `T_FUNCTION' in C:\wamp\www\Opticien\application\default\controllers\adminController.php on line 21
et voici le code du fichier admincontroller.php
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?php
class AdminController extends Zend_Controller_Action
{
public function init()
{
$this->initView();
$this->view->baseUrl = $this->_request->getBaseUrl();
}
public function loginAction()
{
$this->view->title="- Login";
$form = new FormulaireAdmin();
$this->view->form = $form;
}
// Si l'utilisateur est déjà loggué on le redirige à l'accueil
if(Zend_Auth::getInstance()->hasIdentity()) $this->_redirect('/index');
$this->view->title="Mon Site Web - Login";
$form = new FormulaireAdmin();
$this->view->form = $form;
if($this->getRequest()->isPost()) {
if ($form->isValid($_POST)) {
$f = new Zend_Filter_StripTags();
$login = $f->filter($form->getValue('login'));
$password = $f->filter($form->getValue('password'));
$dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('admin');
$authAdapter->setIdentityColumn('login');
$authAdapter->setCredentialColumn('password');
// On assigne les valeurs pour que l'authentification s'effectue
$authAdapter->setIdentity($login);
$authAdapter->setCredential(sha1($password)); // On a pris la
précaution d'au moins chiffrer les mdp
// On tente l'authentification
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
// On test si tout s'est bien passé
if($result->isValid())
{
$data = $authAdapter->getResultRowObject(null,
'password');
$auth->getStorage()->write($data);
$this->_redirect('/admin');
}
else
{
$this->view->error = 'Mauvais login ou mauvais mot de
passe.';
$form->populate($formData);
}
}
else {
$this->view->error = 'Vous devez remplir tous les champs.';
$form->populate($formData);
}
}
} |
Ou est le problème donc?
Et merci pour vos réponses