edit: replace save confirmation by page close protection
[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                 $target = ltrim(@$_GET['goto'], '/');
12                 header("Location: /$target");
13                 http_response_code(302);
14                 exit;
15         }
16
17         echo '<p class="warn">Ongeldige gebruikersnaam of wachtwoord.</p>'."\n\n";
18 }
19 elseif (!empty($User)) {
20         setcookie('login', '', time(), '/'); # expire immediately
21         echo '<p class="warn">Uitgelogd.</p>'."\n\n";
22 }
23
24 ?>
25 <form action="" method="post">
26         <input id="login" name="login" placeholder="Huisnummer" />
27         <input id="pass" name="pass" type="password" value="" placeholder="Wachtwoord" />
28         <input type="submit" value="Log in" />
29 </form>