Visa Källkod

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

NamnTypStorlek
admin.phpPHP Fil7.4 KB
change_password.phpPHP Fil1.6 KB
check_login.phpPHP Fil183 B
delete_user.phpPHP Fil641 B
guestbook.jsonJSON Fil623 B
guestbook.phpPHP Fil5.5 KB
index.phpPHP Fil1.9 KB
login.phpPHP Fil1.6 KB
logout.phpPHP Fil341 B
register.phpPHP Fil872 B
users.jsonJSON Fil1.9 KB

index.php

56 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
session_start
();
?>
<!doctype html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Inloggningsapplikation</title>
    <link rel="stylesheet" href="style.css">
    <link rel="icon" href="../../m02/Favicon-a.jpg" type="image/x-icon">
</head>
<body>
<div class="center-wrap">
  <div>
    <?php
    
// Notice: konto raderat
    
if (isset($_GET['deleted'])) {
        echo 
'<div class="notice error" id="top-notice">Ditt konto har raderats.</div>';
    }
    
// Notice: fel login-data
    
if (isset($_GET['error'])) {
        echo 
'<div class="notice error" id="top-notice">Fel: Användarnamn eller lösenord är felaktigt.</div>';
    }
    
// Notice: feedback efter registrering
    
if (isset($_GET['regsuccess'])) {
        echo 
'<div class="notice success" id="top-notice">Konto skapat! Du kan nu logga in.</div>';
    }
    if (isset(
$_GET['regerror'])) {
        if (
$_GET['regerror'] === 'upptaget') {
            
$msg 'Användarnamnet är redan upptaget.';
        } else {
            
$msg 'Fyll i alla fält!';
        }
        echo 
'<div class="notice error" id="top-notice">' $msg '</div>';
    }
    
?>
  </div>
  <div id="frm1">
    <form action="login.php" method="post">
        <h3 style = "font-size: 1.6rem;">Logga In</h3>
        <input type="text" name="username" placeholder="Användarnamn" required>
        <input type="password" name="password" placeholder="Lösenord" required>
        <button type="submit">Login</button>
    </form>
    <hr>
    <form action="register.php" method="post">
        <h3>Skapa nytt konto</h3>
        <input type="text" name="new_username" placeholder="Nytt användarnamn" required>
        <input type="password" name="new_password" placeholder="Nytt lösenord" required>
        <button type="submit">Skapa konto</button>
    </form>
</div>
</body>
</html>