public function index() { $this->loadModel('login'); $login = new LoginModel(); $this->view->login = ''; if (isset($_POST['login'], $_POST['password'])) { $user = $login->getUserByLogin($_POST['login'], $_POST['password']); if (empty($user)) { $this->view->error = 'Login or Password wrong'; $this->view->login = $_POST['login']; } else { UserGuard::login($user); header('Location: /'); exit; } } $this->view->render('login/index'); }
<html> <head> <title>Test</title> <link rel="stylesheet" href="/public/css/default.css" /> <script src="/public/js/jquery-1.7.2.js"></script> </head> <body> <header> Custom Header <?php if (UserGuard::isLoggedIn()) { ?> <div style="float:right;"> Hello, <?php echo UserGuard::getUserLogin(); ?> ! </div> <?php } ?> </header> <nav> <a href="<?php echo $this->getUrl('home'); ?> ">Home</a> <a href="<?php echo $this->getUrl('help');