Create login form

Please note that this form will perform the user-login inside the template. Hence the user will be logged in from this moment on. Preceding templates will not "know" that the user has been logged in. As a workaround the current page should simply be reloaded after the user has been logged in.

1234567891011121314151617
// DEFINE FORM 
$formname = "login"; 
$FORM->setup($formname, $NAVI->href()); 
$FORM->input("user", "Username"); 
$FORM->input("pass", "Password", "", false, false, false, 1, 1); 
$FORM->submit("Login"); 
$FORM->buffer($FORM->alert()? "Wrong username or password": ""); 
$FORM->close(); 
 
// GET FORM VALUES 
$val = $FORM->values($formname); 
 
// CHECK LOGIN STATUS 
switch(true){ 
case $USER->login(): echo '<a href="' .$NAVI->logout() .'">LOGOUT</a>'; break; 
case $FORM->done($formname) && ($USER->login($val["user"], $val["pass"]) > 0): echo 'LOGIN OK'; break; 
default: $FORM->display($formname); break;}