class LoginController extends Gdn_Controller { public function index($sender) { if ($sender->Form->authenticatedPostBack() === true) { $user = Gdn::authenticator()->checkCredentials( $sender->Form->getValue('username'), $sender->Form->getValue('password') ); if ($user !== false) { // logged in successfully $sender->informMessage('Welcome ' . $user->Name . '!'); } else { // login failed $sender->validation->addValidationResult('Invalid login credentials.'); } } $sender->render(); } }
Form->open(['action' => url('login'), 'method' => 'post']); echo $this->Form->input('username', ['type' => 'text']); echo $this->Form->input('password', ['type' => 'password']); echo $this->Form->button('Submit'); echo $this->Form->close(); ?>In this example, the view contains a login form with username and password fields, and a submit button. The PHP Gdn structure is part of the Garden package library, which includes other libraries and modules for building web applications. Some of these packages include: - Garden Core: the core library that provides the basic functions and classes for the PHP Gdn structure - Garden Authentication: provides authentication and authorization functions - Garden Database: provides a database access layer for working with MySQL, PostgreSQL, and SQLite databases - Garden Text: provides string manipulation and text processing functions.