require_once "models/dbcontroller.php"; if (!securePage($_SERVER['PHP_SELF'])) { die; } //Prevent the user visiting the logged in page if he is not logged in if (!isUserLoggedIn()) { header("Location: admin.php"); die; } if (isset($_POST['date']) && isset($_POST['title']) && isset($_POST['description'])) { if ($_POST['date'] == "") { header("location: admin_corso_completo.php?msg=emptydate"); die; } $originalDate = $_POST['date']; $myDateTime = DateTime::createFromFormat('d/m/Y', $originalDate); $date = $myDateTime->format('Y-m-d'); if ($_POST['title'] == "") { header("location: admin_corso_completo.php?msg=emptytitle"); die; } $title = htmlentities($_POST['title']); $desc = $_POST['description']; if (dbcontroller::createLezioneCorsoCompleto($date, $title, $desc)) { header("location: admin_corso_completo.php?msg=success"); } else { header("location: admin_corso_completo.php?msg=errordb"); } } else { header("location: admin_corso_completo.php?msg=error"); }