page: .private to restrict access to subdirectories
[minimedit.git] / login.php
1 <?php
2 include 'page.inc.php';
3 ?>
4 <h2>Inloggen</h2>
5
6 <?php
7 if (isset($_POST['login'])) {
8         if ($user = login($_POST['login'], $_POST['pass'])) {
9                 setcookie('login', $user['auth'], 0, '/');
10
11                 header("Location: /"); //TODO: goto
12                 http_response_code(302);
13                 exit;
14         }
15
16         echo '<p class="warn">Ongeldige gebruikersnaam of wachtwoord.</p>'."\n\n";
17 }
18 elseif (!empty($User)) {
19         setcookie('login', '', time(), '/'); # expire immediately
20         echo '<p class="warn">Uitgelogd.</p>'."\n\n";
21 }
22
23 ?>
24 <form action="" method="post">
25         <input id="login" name="login" placeholder="Huisnummer" />
26         <input id="pass" name="pass" type="password" value="" placeholder="Wachtwoord" />
27         <input type="submit" value="Log in" />
28 </form>