File: examples/login/application/controllers/login.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil  >  PHP Skeleton Framework  >  examples/login/application/controllers/login.php  >  Download  
File: examples/login/application/controllers/login.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 5 years ago
Size: 1,811 bytes


Class file image Download

class login extends A_Controller_Action {

index($locator) {
$usersession = $locator->get('UserSession');
$usersmodel = $this->_load()->model('Users');
$form = new A_Model_Form();
$base = $locator->get('Config')->get('BASE');
// If the user is loged in:
if ( $usersession->isLoggedIn() ) {
// and wants to log out
if($this->request->get('op') == 'logout') {
$this->_flash('Message', 'You are now logged-out');
// For now I do a redirect but you can also do:
                //$layout = $this->_load()->template('login.tpl');
                //$layout->set('message', 'you are now loged out');
} else {
// else just show the logout form
$layout = $this->_load()->template('logout');
$layout->set('BASE', $base);
$layout->set('message', 'Please log out');
        } else {
// If not loged in and user wants to log in
$layout = $this->_load()->template('login');
            if (
$this->_request('op') == 'login') {
$form->isValid($this->request)) {
                    if (
$row = $usersmodel->findAuthorized($form->get('username'), $form->get('password'))) {

$this->_flash('Message', 'You are now logged-in');
$url = 'http://skeleton/examples/login/';
            } else {
$layout->set('message', 'Please log in');
$layout->set('errmsg', 'Please fill in correct username and password');
$layout->set('errmsg', $form->getErrorMsg(' ,'));
$layout->set('BASE', $base);
$layout->set('username', $form->get('username'));


For more information send a message to info at phpclasses dot org.