summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/code/proben/insert.php
blob: df0e257d3defc446fa5bb4483e638a68bc72fb09 (plain)
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
<?php

require_once __DIR__ . '/../db.php';
require_once __DIR__ . '/../session.php';

$db = get_db();

$termin = $_REQUEST["termin"];
$uhrzeit = $_REQUEST["uhrzeit"];
#$bemerkung = $_REQUEST["bemerkung"];

try {
	$stmt = $db->prepare("INSERT INTO proben (id, termin, uhrzeit, bemerkung) VALUES(NULL, :termin, :uhrzeit, :bemerkung);");

	$stmt->bindValue(":termin", $termin);
	$stmt->bindValue(":uhrzeit", $uhrzeit);
	$stmt->bindValue(":bemerkung", null);

	$stmt->execute();
} catch ( Exception $e ) {
	$_SESSION["error"] = $e->getMessage();
	error_log($e->getMessage());
}

if ( empty($_SESSION) || is_null($_SESSON["error"]) ) {
	$_SESSION["success"] = "Erfolgreich eingetragen!";
}
header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
header("Location: /");