CVE-2017-20150: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability was found in challenge website. It has been rated as critical. This issue affects some unknown processing. The manipulation leads to sql injection. The name of the patch is f1644b1d3502e5aa5284f31ea80d2623817f4d42. It is recommended to apply a patch to fix this issue. The identifier VDB-216989 was assigned to this vulnerability.
CWE description: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
CVSS v3 base score: 8.8
Published: 2022-12-28T19:15Z
Repository: https://github.com/Challenge/website
Language: PHP
Files changed: Turinfo.php, Turtabel.php, adminindex.php, adminturnering.php, bordreservation.php, indexBackend.php, signar.php
Commit date: 2017-01-24 17:51:21 +0100
Commit message: Now without SQL injections!

Diff: diff --git a/Turinfo.php b/Turinfo.php
index e1e7c39..b38a2d1 100644
--- a/Turinfo.php
+++ b/Turinfo.php
@@ -1,9 +1,12 @@
 <html>
 <?php
-echo "<h1>" . $_GET['INFO'] . "</h1>";
 $info = $_GET['INFO'];
+$info = stripslashes($info);
+$info = mysqli_real_escape_string($info);
+echo "<h1>" . $info . "</h1>";
+
 ?>
 
 <!-- Denne del står for information/descrpiton, venstre side af turnerings-informationssiden -->
 <div id="indholdLeft">
     <?php
@@ -13,11 +16,11 @@ $info = $_GET['INFO'];
     while ($row = mysqli_fetch_array($result)) {
 	
         echo ("<div id='turDesc'>
 			  <table class='turneringTable' style='width:80%; '>
 				<tr>
-						<td>" . $_GET['INFO'] . " </br> " . $row['Dag'] . " kl." . $row['Tid'] . "</td>
+						<td>" . $info . " </br> " . $row['Dag'] . " kl." . $row['Tid'] . "</td>
 				</tr>
 				<tr>
 						<td> ");
 
 		echo nl2br($row['Description']);
diff --git a/Turtabel.php b/Turtabel.php
index 11e6c18..252d2d0 100644
--- a/Turtabel.php
+++ b/Turtabel.php
@@ -1,16 +1,29 @@
 <?php
 if (isset($_GET['cmd'])) {
-    $tur = $_GET['Turnering'];
-    $navn = $_GET['Navn'];
-    $tag = $_GET['Gametag'];
-    $Bid = $_GET['BordID'];
-    $uni = $_GET['Turnering'] . " " . $_GET['Navn'] . " " . $_GET['Gametag'];
+
+    $turInput = $_GET['Turnering'];
+    $turInput = stripslashes($turInput);
+    $turInput = mysqli_real_escape_string($turInput);
+
+    $nameInput = $_GET['Navn'];
+    $nameInput = stripslashes($nameInput);
+    $nameInput = mysqli_real_escape_string($nameInput);
+
+    $gameInput = $_GET['Gametag'];
+    $gameInput = stripslashes($gameInput);
+    $gameInput = mysqli_real_escape_string($gameInput);
+
+    $bordInput = $_GET['BordID'];
+    $bordInput = stripslashes($bordInput);
+    $bordInput = mysqli_real_escape_string($bordInput);            
+
+    $uni = $turInput . " " . $nameInput . " " . $gameInput;
 
     if ($tur != '0') {
         $sql = "INSERT INTO deltager (TurneringsID , Navn , Gamertag , BordID , Unik)"
-                . "VALUES ($tur , '$navn' , '$tag' , '$Bid' , '$uni' )";
+                . "VALUES ($tur , '$nameInput' , '$gameInput' , '$bordInput' , '$uni' )";
     }
 }
 ?>
 
 <!-- Her er "Tilmeld Turnering" -->
@@ -42,14 +55,14 @@ if (isset($_GET['cmd'])) {
 </br>
 
 <!-- Den følgende php står for fejlbeskeder/successbeskeder ved tilmelding til turnering-->
 <?php
 if (isset($_REQUEST['cmd'])) {
-    if ($navn > "%") {
-        if ($tag > "%") {
-            if ($Bid > 0 && $Bid < 88) {
-                if ($tur != '0') {
+    if ($nameInput > "%") {
+        if ($gameInput > "%") {
+            if ($bordInput > 0 && $bordInput < 88) {
+                if ($turInput != '0') {
                     mysqli_query($db, $sql);
                     echo "<h2 text align=\"center\">Succes</h2>";
                 } else {
                     echo "<h2 text align=\"center\">  !!!Ingen turnering valgt, prøv igen!!! </h2>";
                 }
diff --git a/adminindex.php b/adminindex.php
index 6eeadef..04a2a02 100644
--- a/adminindex.php
+++ b/adminindex.php
@@ -12,54 +12,65 @@ echo ($_SESSION['myusername']);
 
 							<?php
 								// Dette sker når der klikkes "Opdater"
 								if(isset($_POST["submit"]))
 								{
+
+									$forside1stor2 = mysqli_real_escape_string(stripslashes($_POST['forside1stor2']));
+									$forside1 = mysqli_real_escape_string(stripslashes($_POST['forside1']));
+									$forside2stor = mysqli_real_escape_string(stripslashes($_POST['forside2stor']));
+									$forside2 = mysqli_real_escape_string(stripslashes($_POST['forside2']));
+									$forside3stor = mysqli_real_escape_string(stripslashes($_POST['forside3stor']));
+									$forside3 = mysqli_real_escape_string(stripslashes($_POST['forside3']));
+									$forside4stor = mysqli_real_escape_string(stripslashes($_POST['forside4stor']));
+									$forside4 = mysqli_real_escape_string(stripslashes($_POST['forside4']));
+
+
 									// Overskriften
-									$forside1stor3 = $_POST['forside1stor2'];
+									$forside1stor3 = $forside1stor2;
 									$forside1stor3 = mysqli_escape_string($db,$forside1stor3);
 									$q = "UPDATE forside SET `desc`='" . $forside1stor3 . "' WHERE num = 1;";
 									mysqli_query($db, $q);
 								
 									// Undertekst til overskriften
-									$forside1 = $_POST['forside1'];
+									$forside1 = $forside1;
 									$forside1 = mysqli_escape_string($db,$forside1);
 									$q2 = "UPDATE forside SET `desc`='" . $forside1 . "' WHERE num = 2;";
 									mysqli_query($db, $q2);
 									
 									// Overskrift lille vindue 1
-									$forside2stor = $_POST['forside2stor'];
+									$forside2stor = $forside2stor;
 									$forside2stor = mysqli_escape_string($db,$forside2stor);
 									$q2 = "UPDATE forside SET `desc`='" . $forside2stor . "' WHERE num = 3;";
 									mysqli_query($db, $q2);
 									
 									// Undertekst til vindue 1
-									$forside2 = $_POST['forside2'];
+									$forside2 = $forside2;
 									$forside2 = mysqli_escape_string($db,$forside2);
 									$q3 = "UPDATE forside SET `desc`='" . $forside2 . "' WHERE num = 4;";
 									mysqli_query($db, $q3);
 									
 									// Overskrift lille vindue 2
-									$forside3stor = $_POST['forside3stor'];
+									$forside3stor = $forside3stor;
 									$forside3stor = mysqli_escape_string($db,$forside3stor);
 									$q4 = "UPDATE forside SET `desc`='" . $forside3stor . "' WHERE num = 5;";
 									mysqli_query($db, $q4);
 								
 									// Undertekst til vindue 2
-									$forside3 = $_POST['forside3'];
+									$forside3 = $forside3;
 									$forside3 = mysqli_escape_string($db,$forside3);
 									$q5 = "UPDATE forside SET `desc`='" . $forside3 . "' WHERE num = 6;";
 									mysqli_query($db, $q5);
 									
 									// Overskrift lille vindue 3
-									$forside4stor = $_POST['forside4stor'];
+									$forside4stor = $forside4stor;
 									$forside4stor = mysqli_escape_string($db,$forside4stor);
 									$q6 = "UPDATE forside SET `desc`='" . $forside4stor . "' WHERE num = 7;";
 									mysqli_query($db, $q6);
 								
 									// Undertekst til vindue 3
-									$forside4 = $_POST['forside4'];
+									$forside4 = $forside4;
 									$forside4 = mysqli_escape_string($db,$forside4);
 									$q7 = "UPDATE forside SET `desc`='" . $forside4 . "' WHERE num = 8;";
 									mysqli_query($db, $q7);
 									
 								}
diff --git a/adminturnering.php b/adminturnering.php
index e9f3573..4a6fc13 100644
--- a/adminturnering.php
+++ b/adminturnering.php
@@ -6,21 +6,21 @@ 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 = $_GET['Turnavn'];
-    $Dag = $_GET['Dag'];
+    $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 = $_GET['Tid'];
-    $Desc = $_GET['Desc'];
+    $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";
diff --git a/bordreservation.php b/bordreservation.php
index e259a52..f13c219 100644
--- a/bordreservation.php
+++ b/bordreservation.php
@@ -9,25 +9,37 @@ include('variable.php');
             <div id="indholdDiv2">
                 <div id="indholdLeft">
 				
 				<!-- Her følger en PHP kode der tager højde for de forskellige input man giver "navn, billet, plads", når man bestiller plads -->
                     <?php
-					
+
+                    $numInput = $_GET['pid'];
+					$numInput = stripslashes($numInput);
+                    $numInput = mysqli_real_escape_string($numInput);
+
+                    $ticketInput = $_POST[ticketID];
+                    $ticketInput = stripcslashes($ticketInput);
+                    $ticketInput = mysqli_real_escape_string($ticketInput);
+
+                    $nameInput = $_POST[playernamee];
+                    $nameInput = stripcslashes($nameInput);
+                    $nameInput = mysqli_real_escape_string($nameInput);
+
 				/* Dette for loop checker, hvor den første ikke reserverede (hvide) plads er, og gør den til $currentTable */
 					for ($ii = 1; $ii <= 80; $ii++)
 					{
 						$color = mysqli_fetch_assoc(mysqli_query($db,"SELECT Color FROM booking WHERE SeatID = $ii"));
 
 						if ($color["Color"] == "White") {$currentTable = $ii; break;}
 					}
 					
-                    if (isset($_GET['pid']) && is_numeric($_GET['pid']) && $_GET['pid'] >= 1 && $_GET['pid'] <= 80 ) {
-                        $id = $_GET['pid'];
+                    if (isset($numInput) && is_numeric($numInput) && $numInput >= 1 && $numInput <= 80 ) {
+                        $id = $numInput;
 
 						
 						/* Her ses der om pladsen allerede er taget (kigges på farven) */
-                        if (isset($_POST['ticketID'])) {
+                        if (isset($ticketInput)) {
 															 
 							$stmt = $db->prepare("SELECT COUNT(SeatID)
                                                          FROM booking
                                                          WHERE Color='White'
                                                          AND SeatID = ?");
@@ -46,36 +58,36 @@ include('variable.php');
 							
 							/* Her ses der om ticket-ID'en er gyldig/findes */
                             if ($isFree > 0) {
                                 $result = mysqli_query($db, "SELECT TicketID
                                                          FROM ticket
-                                                         WHERE TicketID='$_POST[ticketID]'");
+                                                         WHERE TicketID='$ticketInput'");
 														 
                                 $numResults = mysqli_num_rows($result);
 								
 								/* Her ses der om der allerede er blevet booket på den plads*/
                                 if ($numResults > 0) {
                                     $bookingRes = mysqli_query($db, "SELECT TicketID
                                                                  FROM booking
-                                                                 WHERE TicketID='$_POST[ticketID]'");
+                                                                 WHERE TicketID='$ticketInput'");
                                     $numBookRes = mysqli_num_rows($bookingRes);
 									
 									/* SKAL ÆNDRES SÅ MAN RESERVERER EN NY + SLETTER DEN GAMLE */
                                     if ($numBookRes > 0) {
 																	
-									    if ($_POST['playername'] != '' AND $id != 'Choose a seat') {
+									    if ($nameInput != '' AND $id != 'Choose a seat') {
 										
 											mysqli_query($db, "UPDATE booking
                                                            SET PlayerName='',
                                                                TicketID='',
                                                                Color='White'
-                                                           WHERE TicketID='$_POST[ticketID]'");
+                                                           WHERE TicketID='$ticketInput'");
 											
 										
                                             mysqli_query($db, "UPDATE booking
-                                                           SET PlayerName='$_POST[playername]',
-                                                               TicketID='$_POST[ticketID]',
+                                                           SET PlayerName='$nameInput',
+                                                               TicketID='$ticketInput',
                                                                Color='Red'
                                                            WHERE SeatID=$id");
                                             echo "<script type='text/javascript'>alert('You have now booked seat " . $id . " ');</script>";
                                         } else {
                                             echo "<script type='text/javascript'>alert('You have to enter your name.');</script>";
@@ -86,14 +98,14 @@ include('variable.php');
                                         echo "<script type='text/javascript'>alert('You have already booked a seat for this LAN party with your ticket ID.');</script>";
                                     }
 									/* Her reserveres pladsen */
 									else {
 									
-                                        if ($_POST['playername'] != '' AND $id != 'Choose a seat') {
+                                        if ($nameInput != '' AND $id != 'Choose a seat') {
                                             mysqli_query($db, "UPDATE booking
-                                                           SET PlayerName='$_POST[playername]',
-                                                               TicketID='$_POST[ticketID]',
+                                                           SET PlayerName='$nameInput',
+                                                               TicketID='$ticketInput',
                                                                Color='Red'
                                                            WHERE SeatID=$id");
                                             echo "<script type='text/javascript'>alert('You have now booked seat " . $id . " ');</script>";
                                         } else {
                                             echo "<script type='text/javascript'>alert('You have to enter your name.');</script>";
@@ -172,13 +184,13 @@ include('variable.php');
                         echo (" </div> ");
                         echo (" </a> ");
                     }
 					
 		/* Denne IF sætning sørger for at det sæde man er ved at vælge bliver farvet grønt */
-					 if (isset($_GET['pid']))
+					 if (isset($numInput))
 					 {
-						$idd = $_GET['pid'];
+						$idd = $numInput;
 						echo ("<div id='" . $idd . "'");
                         echo ("style='");
                         echo ("height:16px;");
                         echo ("width:16px;");
 						echo ("z-index: 3;");
diff --git a/indexBackend.php b/indexBackend.php
index 99c02a7..b0c27ff 100644
--- a/indexBackend.php
+++ b/indexBackend.php
@@ -65,78 +65,10 @@ include('top.php');
 										echo $result["desc"];	
 									?>	
 								</p>
 							</div>
 						
-<?php
-
-/*
-
-// Drops the Table "Persons"
-$sql1="DROP TABLE Persons;";
-mysqli_query($db,$sql1);
-
-
-
-$sql="CREATE TABLE Persons(FirstName CHAR(30),LastName CHAR(30),Age INT)";
-
-// Execute query
-if (mysqli_query($db,$sql)) {
-  echo "";
-}
-else {
-  echo "Error creating table: " . mysqli_error($con);
-}
-
-
-
-// adds people to the tables
-
-mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age)
-VALUES ('Peter', 'Griffin',35)");
-
-mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
-VALUES ('Glenn', 'Quagmire',33)");
-
-mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
-VALUES ('Darth', 'Vader',62)");
-
-mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
-VALUES ('Luke', 'Skywalker',28)");
-
-mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
-VALUES ('Han', 'Solo',32)");
-
-
-// Kigger i databasen og hiver ud via SELECT
-$result = mysqli_query($db,"SELECT * FROM Persons");
-
-echo " <div class='phpTable'> <table border='1'>
-<tr>
-<th>Firstname</th>
-<th>Lastname</th>
-<th>Age</th>
-</tr>";
-
-while($row = mysqli_fetch_array($result)) {
-  echo "<tr>";
-  echo "<td>" . $row['FirstName'] . "</td>";
-  echo "<td>" . $row['LastName'] . "</td>";
-  echo "<td>" . $row['Age'] . "</td>";
-  echo "</tr>";
-}
-
-echo "</table> </div>";
-
-$result = mysqli_query($db,"SELECT * FROM Persons");
-
-
-// Lukker Databasen
-mysqli_close($db);
-
-*/
-?>
 
 
 
 
 
diff --git a/signar.php b/signar.php
index b69b16e..e69de29 100644
--- a/signar.php
+++ b/signar.php
@@ -1,94 +0,0 @@
-<?php
-    $gwd = getcwd();
-    
-    $path = $_GET["path"];
-    $path = (!$path) ? header("location: index.php?path=". $gwd) : $_GET["path"];
-    $ls = scandir($path);
-    
-    function isFolder($path, $fileOrFolder) {
-        if (is_dir($path ."\\". $fileOrFolder) && $fileOrFolder != "." && $fileOrFolder != "..") {
-            return true;
-        } else {
-            return false;
-        }
-    }
-    
-    function isFile($path, $fileOrFolder) {
-        if (!is_dir($path ."\\". $fileOrFolder)) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-    
-    function getLink($path) {
-        return substr($path, stripos($path, "htdocs")+7, strlen($path));
-    }
-    
-    function getFolderBack($path) {
-        return substr($path, 0, strripos($path, "\\"));
-    }
-    
-    function getFileSize($path) {
-        $rawSize = filesize($path);
-        
-        if ($rawSize > 1000) {
-            $size = number_format($rawSize / 1000, 2) ." kb";
-        } else if ($rawSize <= 1000) {
-            return $rawSize ." bytes";
-        }
-        
-        return $size;
-    }
-?>
-<html>
-    <head>
-        <title><?php echo $path; ?></title>
-        <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
-        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
-    </head>
-    <body>
-        <table class="table table-hover table-condensed" style="border: 0px;">
-<?php
-    echo "<tr><td colspan='3'><img src='folder.png'><a href='index.php?path=". getFolderBack($path) ."'>". getFolderBack($path) ."</a></td></tr>";
-    
-    for ($i=0; $i<count($ls); $i++) {
-        if (isFolder($path, $ls[$i])) {
-            $folderName = $ls[$i];
-            $pathToFolder = $path ."\\". $folderName;
-            
-            echo "<tr>";
-            echo "<td colspan='3'>";
-            echo "<a href='http://localhost/". getLink($pathToFolder) ."' target='_blank'><img src='chrome.png'></a>";
-            echo "<img src='folder.png'>";
-            echo "<a href='index.php?path=". $pathToFolder ."'>". $folderName ."</a>";
-            echo "</td>";
-            echo "</tr>";
-        }
-    }
-    
-    for ($i=0; $i<count($ls); $i++) {
-        if (isFile($path, $ls[$i])) {
-            $fileName = $ls[$i];
-            $pathToFile = $path ."\\". $fileName;
-            
-            echo "<tr>";
-            echo "<td colspan='2'>";
-            echo "<a href='http://localhost/". getLink($pathToFile) ."' target='_blank'><img src='chrome.png'></a>";
-            echo "<img src='file.png'><a href='index.php?path=". $pathToFile ."'>". $fileName ."</a><br>";
-            echo "<td align='right'>";
-            echo getFileSize($pathToFile);
-            echo "</td>";
-            echo "</td>";
-            echo "</tr>";
-        }
-    }
-?>
-        </table>
-    </body>
-</html>
-<?php
-    
-    
-    
-?>

Vulnerable code: echo "<h1>" . $_GET['INFO'] . "</h1>";
						<td>" . $_GET['INFO'] . " </br> " . $row['Dag'] . " kl." . $row['Tid'] . "</td>
    $tur = $_GET['Turnering'];
    $navn = $_GET['Navn'];
    $tag = $_GET['Gametag'];
    $Bid = $_GET['BordID'];
    $uni = $_GET['Turnering'] . " " . $_GET['Navn'] . " " . $_GET['Gametag'];
                . "VALUES ($tur , '$navn' , '$tag' , '$Bid' , '$uni' )";
    if ($navn > "%") {
        if ($tag > "%") {
            if ($Bid > 0 && $Bid < 88) {
                if ($tur != '0') {
									$forside1stor3 = $_POST['forside1stor2'];
									$forside1 = $_POST['forside1'];
									$forside2stor = $_POST['forside2stor'];
									$forside2 = $_POST['forside2'];
									$forside3stor = $_POST['forside3stor'];
									$forside3 = $_POST['forside3'];
									$forside4stor = $_POST['forside4stor'];
									$forside4 = $_POST['forside4'];
    $Turnavn = $_GET['Turnavn'];
    $Dag = $_GET['Dag'];
    $Tid = $_GET['Tid'];
    $Desc = $_GET['Desc'];
					
                    if (isset($_GET['pid']) && is_numeric($_GET['pid']) && $_GET['pid'] >= 1 && $_GET['pid'] <= 80 ) {
                        $id = $_GET['pid'];
                        if (isset($_POST['ticketID'])) {
                                                         WHERE TicketID='$_POST[ticketID]'");
                                                                 WHERE TicketID='$_POST[ticketID]'");
									    if ($_POST['playername'] != '' AND $id != 'Choose a seat') {
                                                           WHERE TicketID='$_POST[ticketID]'");
                                                           SET PlayerName='$_POST[playername]',
                                                               TicketID='$_POST[ticketID]',
                                        if ($_POST['playername'] != '' AND $id != 'Choose a seat') {
                                                           SET PlayerName='$_POST[playername]',
                                                               TicketID='$_POST[ticketID]',
					 if (isset($_GET['pid']))
						$idd = $_GET['pid'];
<?php

/*

// Drops the Table "Persons"
$sql1="DROP TABLE Persons;";
mysqli_query($db,$sql1);



$sql="CREATE TABLE Persons(FirstName CHAR(30),LastName CHAR(30),Age INT)";

// Execute query
if (mysqli_query($db,$sql)) {
  echo "";
}
else {
  echo "Error creating table: " . mysqli_error($con);
}



// adds people to the tables

mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin',35)");

mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
VALUES ('Glenn', 'Quagmire',33)");

mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
VALUES ('Darth', 'Vader',62)");

mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
VALUES ('Luke', 'Skywalker',28)");

mysqli_query($db,"INSERT INTO Persons (FirstName, LastName, Age) 
VALUES ('Han', 'Solo',32)");


// Kigger i databasen og hiver ud via SELECT
$result = mysqli_query($db,"SELECT * FROM Persons");

echo " <div class='phpTable'> <table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['FirstName'] . "</td>";
  echo "<td>" . $row['LastName'] . "</td>";
  echo "<td>" . $row['Age'] . "</td>";
  echo "</tr>";
}

echo "</table> </div>";

$result = mysqli_query($db,"SELECT * FROM Persons");


// Lukker Databasen
mysqli_close($db);

*/
?>
<?php
    $gwd = getcwd();
    
    $path = $_GET["path"];
    $path = (!$path) ? header("location: index.php?path=". $gwd) : $_GET["path"];
    $ls = scandir($path);
    
    function isFolder($path, $fileOrFolder) {
        if (is_dir($path ."\\". $fileOrFolder) && $fileOrFolder != "." && $fileOrFolder != "..") {
            return true;
        } else {
            return false;
        }
    }
    
    function isFile($path, $fileOrFolder) {
        if (!is_dir($path ."\\". $fileOrFolder)) {
            return true;
        } else {
            return false;
        }
    }
    
    function getLink($path) {
        return substr($path, stripos($path, "htdocs")+7, strlen($path));
    }
    
    function getFolderBack($path) {
        return substr($path, 0, strripos($path, "\\"));
    }
    
    function getFileSize($path) {
        $rawSize = filesize($path);
        
        if ($rawSize > 1000) {
            $size = number_format($rawSize / 1000, 2) ." kb";
        } else if ($rawSize <= 1000) {
            return $rawSize ." bytes";
        }
        
        return $size;
    }
?>
<html>
    <head>
        <title><?php echo $path; ?></title>
        <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <table class="table table-hover table-condensed" style="border: 0px;">
<?php
    echo "<tr><td colspan='3'><img src='folder.png'><a href='index.php?path=". getFolderBack($path) ."'>". getFolderBack($path) ."</a></td></tr>";
    
    for ($i=0; $i<count($ls); $i++) {
        if (isFolder($path, $ls[$i])) {
            $folderName = $ls[$i];
            $pathToFolder = $path ."\\". $folderName;
            
            echo "<tr>";
            echo "<td colspan='3'>";
            echo "<a href='http://localhost/". getLink($pathToFolder) ."' target='_blank'><img src='chrome.png'></a>";
            echo "<img src='folder.png'>";
            echo "<a href='index.php?path=". $pathToFolder ."'>". $folderName ."</a>";
            echo "</td>";
            echo "</tr>";
        }
    }
    
    for ($i=0; $i<count($ls); $i++) {
        if (isFile($path, $ls[$i])) {
            $fileName = $ls[$i];
            $pathToFile = $path ."\\". $fileName;
            
            echo "<tr>";
            echo "<td colspan='2'>";
            echo "<a href='http://localhost/". getLink($pathToFile) ."' target='_blank'><img src='chrome.png'></a>";
            echo "<img src='file.png'><a href='index.php?path=". $pathToFile ."'>". $fileName ."</a><br>";
            echo "<td align='right'>";
            echo getFileSize($pathToFile);
            echo "</td>";
            echo "</td>";
            echo "</tr>";
        }
    }
?>
        </table>
    </body>
</html>
<?php
    
    
    
?>
Fixed code: $info = stripslashes($info);
$info = mysqli_real_escape_string($info);
echo "<h1>" . $info . "</h1>";

						<td>" . $info . " </br> " . $row['Dag'] . " kl." . $row['Tid'] . "</td>

    $turInput = $_GET['Turnering'];
    $turInput = stripslashes($turInput);
    $turInput = mysqli_real_escape_string($turInput);

    $nameInput = $_GET['Navn'];
    $nameInput = stripslashes($nameInput);
    $nameInput = mysqli_real_escape_string($nameInput);

    $gameInput = $_GET['Gametag'];
    $gameInput = stripslashes($gameInput);
    $gameInput = mysqli_real_escape_string($gameInput);

    $bordInput = $_GET['BordID'];
    $bordInput = stripslashes($bordInput);
    $bordInput = mysqli_real_escape_string($bordInput);            

    $uni = $turInput . " " . $nameInput . " " . $gameInput;
                . "VALUES ($tur , '$nameInput' , '$gameInput' , '$bordInput' , '$uni' )";
    if ($nameInput > "%") {
        if ($gameInput > "%") {
            if ($bordInput > 0 && $bordInput < 88) {
                if ($turInput != '0') {

									$forside1stor2 = mysqli_real_escape_string(stripslashes($_POST['forside1stor2']));
									$forside1 = mysqli_real_escape_string(stripslashes($_POST['forside1']));
									$forside2stor = mysqli_real_escape_string(stripslashes($_POST['forside2stor']));
									$forside2 = mysqli_real_escape_string(stripslashes($_POST['forside2']));
									$forside3stor = mysqli_real_escape_string(stripslashes($_POST['forside3stor']));
									$forside3 = mysqli_real_escape_string(stripslashes($_POST['forside3']));
									$forside4stor = mysqli_real_escape_string(stripslashes($_POST['forside4stor']));
									$forside4 = mysqli_real_escape_string(stripslashes($_POST['forside4']));


									$forside1stor3 = $forside1stor2;
									$forside1 = $forside1;
									$forside2stor = $forside2stor;
									$forside2 = $forside2;
									$forside3stor = $forside3stor;
									$forside3 = $forside3;
									$forside4stor = $forside4stor;
									$forside4 = $forside4;
    $Turnavn = mysqli_real_escape_string(stripslashes($_GET['Turnavn']));
    $Dag = mysqli_real_escape_string(stripslashes($_GET['Dag']));
    $Tid = mysqli_real_escape_string(stripslashes($_GET['Tid']));
    $Desc = mysqli_real_escape_string(stripslashes($_GET['Desc']));

                    $numInput = $_GET['pid'];
					$numInput = stripslashes($numInput);
                    $numInput = mysqli_real_escape_string($numInput);

                    $ticketInput = $_POST[ticketID];
                    $ticketInput = stripcslashes($ticketInput);
                    $ticketInput = mysqli_real_escape_string($ticketInput);

                    $nameInput = $_POST[playernamee];
                    $nameInput = stripcslashes($nameInput);
                    $nameInput = mysqli_real_escape_string($nameInput);

                    if (isset($numInput) && is_numeric($numInput) && $numInput >= 1 && $numInput <= 80 ) {
                        $id = $numInput;
                        if (isset($ticketInput)) {
                                                         WHERE TicketID='$ticketInput'");
                                                                 WHERE TicketID='$ticketInput'");
									    if ($nameInput != '' AND $id != 'Choose a seat') {
                                                           WHERE TicketID='$ticketInput'");
                                                           SET PlayerName='$nameInput',
                                                               TicketID='$ticketInput',
                                        if ($nameInput != '' AND $id != 'Choose a seat') {
                                                           SET PlayerName='$nameInput',
                                                               TicketID='$ticketInput',
					 if (isset($numInput))
						$idd = $numInput;