View sourcecode

The following files exists in this folder. Click to view.

login.php

43 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
session_start
();
if (isset(
$_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
    
header("Location: admin.php");
    exit;
}


$error = isset($_GET['error']) ? $_GET['error'] : '';
?>

<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <title>Logga in</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h2>Logga in</h2>

    <?php if ($error == 1): ?>
        <p style="color:red;">Fel användarnamn eller lösenord.</p>
    <?php elseif ($error == 2): ?>
        <p style="color:red;">Du måste logga in först.</p>
    <?php endif; ?>

    <form action="check_login.php" method="post">
        <label for="användarnamn">Användarnamn:</label>
        <input type="text" name="användarnamn" id="användarnamn" required><br><br>

        <label for="lösenord">Lösenord:</label>
        <input type="password" name="lösenord" id="lösenord" required><br><br>

        <label>
            <input type="checkbox" name="keepLoggedIn"> Håll mig inloggad
        </label><br><br>

        <button type="submit">Logga in</button>
    </form>
</body>
</html>