-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminturnering.php
149 lines (138 loc) · 6.99 KB
/
adminturnering.php
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
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include('top2.php');
include('isLoggedIn.php');
?>
<!-- Opretter en turnering når der klikkes "Opret turnering",
Sletter en given turnering hvis der klikkes "slet turnering",
og sletter alle turneringer hvis der klikkes "slet alle turneringer" -->
<?php
if (isset($_GET['Opret'])) {
$Turnavn = mysqli_real_escape_string(stripslashes($_GET['Turnavn']));
$Dag = mysqli_real_escape_string(stripslashes($_GET['Dag']));
if ($Dag == '1') {
$DagB = "Fredag";
} else if ($Dag == '2') {
$DagB = "Lørdag";
} else if ($Dag == '3') {
$DagB = "Søndag";
}
$Tid = mysqli_real_escape_string(stripslashes($_GET['Tid']));
$Desc = mysqli_real_escape_string(stripslashes($_GET['Desc']));
$sql = "INSERT INTO `turtabel` (`TurneringsID`, `TurneringsNavn`, `Tid`, `Dag`, `Description`) "
. " VALUES (NULL, '$Turnavn', '$Tid', '$DagB', '$Desc')";
} else if (isset($_GET['slet'])) {
$ID = $_GET['Turid'];
$deletedel = "DELETE FROM `deltager` WHERE `deltager`.`TurneringsID` = $ID";
$deletetur = "DELETE FROM `turtabel` WHERE `turtabel`.`TurneringsID` = $ID";
} else if (isset($_GET['reset'])) {
$truncatedel = "TRUNCATE TABLE `deltager` ";
$truncatetur = "TRUNCATE TABLE `turtabel` ";
}
?>
<!-- Denne del gennemfører slet-kommandoen fra knappen -->
<?php
if (isset($_REQUEST['slet'])) {
if ($ID != 0) {
mysqli_query($db, $deletedel);
mysqli_query($db, $deletetur);
}
} else if (isset($_REQUEST['reset'])) {
mysqli_query($db, $truncatedel);
mysqli_query($db, $truncatetur);
}
?>
<div id="page">
<div id="indhold">
<div id="indholdText2">
<div id="indholdDiv2">
<!-- Her kan der oprettes turneringer som administrator-->
<h2 text align="Center">Opret Turneringer</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="Opret" value="Tur">
<table border=7; bordercolor="#C80000" tabel align="center" >
<tr><td>Turneringens Navn </td><td><input type="text" name="Turnavn"></td></tr>
<tr><td>Dag</td><td>
<select name="Dag">
<option value="0">Vælg Dag</option>
<option value="1">Fredag</option>
<option value="2">Lørdag</option>
<option value="3">Søndag</option>
</select></td>
</tr>
<tr><td>Tid</td><td>
<select name="Tid">
<option value="0">Vælg Tid</option>
<?php
for ($hours = 0; $hours < 24; $hours++) // the interval for hours is '1'
for ($mins = 0; $mins < 60; $mins+=30) // the interval for mins is '30'
echo '<option>' . str_pad($hours, 2, '0', STR_PAD_LEFT) . ':'
. str_pad($mins, 2, '0', STR_PAD_LEFT) . '</option>';
?>
</select></td></tr>
<tr><td>Description</td>
<td><textarea name="Desc" rows="12" cols="25"></textarea>
</td></tr>
<tr><td colspan=2 align=center>
<input type="Submit" value="Submit">
<input type="Reset" value="Reset"></td><td>
<?php
if (isset($_REQUEST['Opret'])) {
if ($Turnavn > "%") {
if ($Dag > 0) {
if ($Tid != 0) {
mysqli_query($db, $sql);
echo "<p text align=\"center\"> Succes <p>";
} else {
echo "<p text align=\"center\"> Error ved tid </p>";
}
} else {
echo "<p text align=\"center\"> Error ved Dag </p>";
}
} else {
echo "<p text align=\"center\"> Error ved navn </p>";
$turnavn = mysqli_query($db, "SELECT TurneringsID , TurneringsNavn "
. "FROM turtabel "
. "ORDER BY turtabel.TurneringsID desc");
while ($row = mysqli_fetch_array($turnavn)) {
echo $row[0] . " ";
}
}
}
?>
</td></tr>
</table>
</form>
<!-- Her kan der slettes enkelte turneringer-->
<h2 text align="Center">Slet enkelte Turneringer</h2>
<form>
<input type="hidden" name="slet" value="DELETE">
<table border=3; bordercolor="#C80000" tabel align="center" >
<tr><td>Turnering </td><td>
<select name="Turid">
<option value="0">Vælg Turnering</option>
<?php
$turnavn = mysqli_query($db, "SELECT TurneringsID , TurneringsNavn "
. "FROM turtabel "
. "ORDER BY turtabel.TurneringsID desc");
while ($row = mysqli_fetch_array($turnavn)) {
echo "<option value=\"$row[0]\"> $row[1]</option>";
}
?>
</select>
<tr><td colspan=2 align=center>
<input type="submit" value="Slet Turneringer"></td></tr>
</table>
</form>
<!-- Her slettes ALLE turneringer-->
<h2 text align="Center">Slet ALLE Turneringer:</h2>
<form form align="center">
<input type="hidden" name="reset" value="Tøm">
<input type="submit" value="Klik her">
</form>
</div>
</div>
</div>
</div>
<?php
include('bottom.html');
?>