<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once ('header.php');
if ($aangemeld == "ja")
{
	if (ISSET($_GET['id']))
	{
		if (ISSET($_GET['change']))
		{
			mysql_query("UPDATE kamers SET naam='".$_GET['naam']."', omschrijf='".$_GET['omschrijf']."', eigenaar='".$_GET['eigenaar']."', type='".$_GET['type']."', safe='".$_GET['safe']."', pass='".$_GET['pass']."', soort='".$_GET['soort']."', vloer='".$_GET['vloer']."', muur='".$_GET['muur']."' WHERE id=".$_GET['id'].";");
			mysql_query("UPDATE items SET eigenaar='".$_GET['eigenaar']."' WHERE kamerused=".$_GET['id'].";");
		}
		echo "<h1>Kamers instellen (ID: ".$_GET['id'].")</h1>";
		echo "<center>";
		echo "<form action='kamers.php' method='get'>";
		echo "ID: <input type='text' length='20' maxlength='20' name='id'>";
		echo "<input type='submit' value='Ga'>";
		echo "</form>";
		echo "</center>";
		error_reporting(0);
   		$bestaat_mss_al = halen("SELECT * FROM kamers WHERE id='".$_GET['id']."';");
	   	error_reporting(E_ALL);
		if($bestaat_mss_al != "")
		{
			$gegevens = halen_array("SELECT * FROM kamers WHERE id='".$_GET['id']."';");
			echo "<center>";
			echo "<form name='change_form' method='get' action='?'>";
			echo "<input type='hidden' name='change' value='change'>";
			echo "<input type='hidden' name='id' value='".$gegevens['id']."'>";
			echo "<table border='1' class='tabel'>";
			echo "<tr>";
    		echo "<td>ID: </td>";
    		echo "<td>".$gegevens['id']."</td>";
    		echo "</tr>";
			echo "<tr>";
    		echo "<td>Views: </td>";
    		echo "<td>".$gegevens['views']."</td>";
    		echo "</tr>";
    		echo "<tr>";
    		echo "<td>Naam: </td>";
    		echo "<td><input type='text' size='50' name='naam' value='".$gegevens['naam']."' maxlength='30'></td>";
    		echo "</tr>";
			echo "<tr>";
    		echo "<td>Omschrijving: </td>";
    		echo "<td><input type='text' size='50' name='omschrijf' value='".$gegevens['omschrijf']."' maxlength='50'></td>";
    		echo "</tr>";
    		echo "<tr>";
    		echo "<td>Eigenaar: </td>";
    		echo "<td><input type='text' size='50' name='eigenaar' value='".$gegevens['eigenaar']."' maxlength='20'></td>";
    		echo "</tr>";
    		echo "<tr>";
    		echo "<td>Type: </td>";
    		echo "<td><input type='text' size='25' name='type' value='".$gegevens['type']."' maxlength='20'> (openbaar?)</td>";
    		echo "</tr>";
    		echo "<tr>";
    		echo "<td>Safe: </td>";
    		echo "<td><input type='text' size='50' name='safe' value='".$gegevens['safe']."' maxlength='50'></td>";
    		echo "</tr>";
    		echo "<tr>";
    		echo "<td>Pass: </td>";
    		echo "<td><input type='text' size='50' name='pass' value='".$gegevens['pass']."' maxlength='15'></td>";
    		echo "</tr>";
			echo "<tr>";
    		echo "<td>Soort: </td>";
    		echo "<td><input type='text' size='25' name='soort' value='".$gegevens['soort']."'> (1-8)</td>";
    		echo "</tr>";
			echo "<tr>";
    		echo "<td>Vloer: </td>";
    		echo "<td><input type='text' size='50' name='vloer' value='".$gegevens['vloer']."' maxlength='50'></td>";
    		echo "</tr>";
			echo "<tr>";
    		echo "<td>Muur: </td>";
    		echo "<td><input type='text' size='50' name='muur' value='".$gegevens['muur']."' maxlength='50'></td>";
    		echo "</tr>";
			echo "</table>";
			echo "<br><input type='submit' value='Wijzig'>";
			echo "</form>";
			echo "</center>";
			action("bekijkt instellingen van kamer met ID: ".$_GET['id']);
		}
		else
		{
			echo "Deze kamer bestaat niet.</center>";
		}
	}
	else
	{
		echo "<h1>Kamers instellen</h1>";
		echo "<center>";
		echo "<form action='kamers.php' method='get'>";
		echo "ID: <input type='text' length='20' maxlength='20' name='id'>";
		echo "<input type='submit' value='Ga'>";
		echo "</form>";
		echo "</center><br>";
	}
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once('footer.php');
?>