getReservationsAdmin.php 789 Bytes
Newer Older
BuildTools's avatar
BuildTools committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?PHP
	if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != "z10" || $_SERVER['PHP_AUTH_PW'] != "kruemel") {
		header('WWW-Authenticate: Basic realm="My Realm"');
		header('HTTP/1.0 401 Unauthorized');
		echo "Passwort oder Benutzername falsch";
		exit;
	}

	$user = 'apache';
	$pass = 'e164AzpQx564TpJa';
	$db = new PDO('mysql:host=localhost;dbname=reservation', $user, $pass);
	
	if ($_POST["withEnded"] == "true") {
		$statement = $db -> prepare("SELECT * FROM reservations WHERE date = ? ORDER BY tisch, start, end ASC");
	} else {
		$statement = $db -> prepare("SELECT * FROM reservations WHERE date = ? AND ended = 0 ORDER BY tisch, start, end ASC");
	}
	$statement->execute(array($_POST["date"]));
	
	echo json_encode($statement->fetchAll());
?>