gymrooster_php/php/update.php

15 lines
752 B
PHP
Executable File

<?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');