Show sourcecode
The following files exists in this folder. Click to view.
access-deneid.png
diagramresultat.php
insert-admin.php
login.php
logout.php
personliga-resultat.php
quiz-sida.php
ransa-quiz-session.php
ransa-skapa-quiz-session.php
resultat.php
session-variabler-unset.php
signin.php
skapa-inloggning-tabell.php
skapa-quiz-tabeller.php
skapa-quiz.php
start.php
tabort-kunder-quiz.php
åtkomst-nekad.php
tabort-kunder-quiz.php
137 lines UTF-8 Windows (CRLF)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
session_start();
include('session-variabler-unset.php');
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] != true){
header("Location: login.php");
exit;
}
if($_SESSION["type"] != "admin"){
header("Location: åtkomst-nekad.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ta bort</title>
<style>
table{
border-collapse:collapse;
margin:20px 0;
font-size:16px;
text-align: left;
}
table,th,td{
border:1px solid #ddd;
}
th,td {
padding: 10px;
}
tr:hover{
background-color:#f1f1f1;
}
caption{
background-color:darkblue;
color:white;
font-weight:bold;
font-size:20px;
}
</style>
</head>
<body>
<?php
include ('../../dbconnection.php');
$id = null;
$id2 = null;
//ta bort kund
if (isset($_POST['id']) && !empty($_POST['id'])) {
$id = $_POST['id'];
try {
$sql = "DELETE FROM kunder WHERE id=?";
$stmt = $dbconn->prepare($sql);
$data = array($id);
$stmt->execute($data);
}
catch(PDOException $e)
{
$e->getMessage();
}
}
//ta bort quiz
if (isset($_POST['id2']) && !empty($_POST['id2'])) {
$id2 = $_POST['id2'];
try {
$sql = "DELETE FROM quizer WHERE id=?";
$stmt = $dbconn->prepare($sql);
$data = array($id2);
$stmt->execute($data);
}
catch(PDOException $e)
{
$e->getMessage();
}
}
//kunder tabell
$sql = "SELECT * FROM kunder";
$stmt = $dbconn->prepare($sql);
$data = array();
$stmt->execute($data);
$output = "<table><caption>Kunder</caption>";
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$idx = htmlentities($res['id']);
$name = htmlentities($res['name']);
$username = htmlentities($res['username']);
$type = htmlentities($res['type']);
$output .= "<tr>".
"<td>$idx</td>".
"<td>$name</td>".
"<td>$username</td>".
"<td>$type</td>".
"<td><form method='post' action=''>".
"<input type='hidden' name='id' value='$idx'>".
"<button type='submit'>Ta bort</button></form></td>".
"</tr>";
}
$output .= "</table>";
echo "$output";
echo "<br>";
//Quizer tabell
$sql = "SELECT * FROM quizer";
$stmt = $dbconn->prepare($sql);
$data = array();
$stmt->execute($data);
$output = "<table><caption>Quizer</caption>";
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$idx2 = htmlentities($res['id']);
$namn = htmlentities($res['namn']);
$output .= "<tr>".
"<td>$idx2</td>".
"<td>$namn</td>".
"<td><form method='post' action=''>".
"<input type='hidden' name='id2' value='$idx2'>".
"<button type='submit'>Ta bort</button></form></td>".
"</tr>";
}
$output .= "</table>";
echo "$output";
$dbconn = null;
?>
<a href="start.php">Tillbaka till start</a>
</body>
</html>