24 lines
		
	
	
		
			632 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			632 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php $app = require '../app/inc.php';
 | |
| 
 | |
| if ($app->user->loggedIn)
 | |
| {
 | |
|     $app->redirect('index.php');
 | |
| }
 | |
| 
 | |
| $username = (string)filter_input(INPUT_POST, 'username');
 | |
| $password = (string)filter_input(INPUT_POST, 'password');
 | |
| 
 | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST')
 | |
| {
 | |
|     if ($app->user->login($username, $password))
 | |
|     {
 | |
|         $app->session->flash("Velkommen {$username}!");
 | |
|         $app->redirect('index.php');
 | |
|     }
 | |
|     http_response_code(401);
 | |
|     $app->session->flash('Feil påloggingsinformasjon', 'danger');
 | |
| }
 | |
| 
 | |
| $app->view('template/header', ["title" => "Logg inn"]);
 | |
| $app->view('pages/login');
 | |
| $app->view('template/footer'); |