Visa Källkod

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

NamnTypStorlek
admin.phpPHP Fil415 B
check_login.phpPHP Fil607 B
index.phpPHP Fil2.5 KB
login.phpPHP Fil985 B
logout.phpPHP Fil585 B

login.php

38 lines ISO-8859-1 BOM Unix (LF) - Type: PHP Fil
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
<?php
session_start
();

// inloggningsuppgifter
$valid_username "Admin";
$valid_password "1234";

if (
$_SERVER["REQUEST_METHOD"] == "POST") {
    
$username $_POST['username'] ?? '';
    
$password $_POST['password'] ?? '';

    if (
$username === $valid_username && $password === $valid_password) {
        
$_SESSION['loggedin'] = true;
        
$_SESSION['username'] = $username;
        
header("Location: admin.php");
        exit;
    } else {
        
header("Location: index.php?error=1");
        exit;
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Inloggningsapplikation</title>
    <link rel="stylesheet" href="style.css">
    <link rel="icon" href="../../m02/Favicon-a.jpg" type="image/x-icon">
</head>
<body>

</body>
</html>