gymrooster_php/php/update.php

15 lines
752 B
PHP
Raw Normal View History

2020-03-09 19:09:41 +01:00
<?php
if (isset($_POST["opmerking"]) && isset($_POST["locatie"]) && isset($_GET["date"]) && isset($_GET['docent'])) {
require 'conn.php';
$result = $conn->query("SELECT * FROM rooster WHERE dag = DATE('" . $_GET["date"] . "') AND docent = " . $_GET['docent'] .";");
if ($result->num_rows === 0) {
$conn->query("INSERT INTO rooster (dag, docent, opmerking, locatie) VALUES (DATE('" . $_GET['date'] . "'), " . $_GET['docent'] . ", '" . $_POST['opmerking'] . "', " . $_POST['locatie'] . ");");
} else {
$conn->query("UPDATE rooster SET opmerking = '" . $_POST["opmerking"] . "', locatie = " . $_POST["locatie"] . " WHERE docent = " . $_GET['docent'] . " AND dag = DATE('" . $_GET['date'] . "');");
}
}
header('Location: /dashboard');