Location: PHPKode > projects > Todo Manager > todo/controllers/login.class.php
<?php
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/controller.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/database.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/activerecord.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/authentication.class.php";

class Login extends Controller {
	var $db;
	var $order;
	var $sense;

	function init() {
		// database connection
		$this->db = new Database(DATABASE_NAME, USER_NAME, PASSWORD);
		
		// authentication
		$this->auth = new Authentication($this->db);
		if ($this->auth->isLogged())
			$this->redirect("index.php");
			
		// messages
		$this->loadMessages("messages/generic", "en");
		$this->loadMessages("messages/login", "en");
	}
	
	function onGet() {
		$this->setParam("remember", "yes");
	}
	
	function onPost() {
		// parameters
		$username = $this->getParam("username");
		$password = $this->getParam("password");
		$remember = $this->getParam("remember");
		
		if (!$this->auth->login($username, $password, $remember)) {
			$this->setError("error", $this->getRawMessage("bad_user_name"));
			return;
		}
		
		$this->redirect("index.php");
	}
}
?>
Return current item: Todo Manager