if (!isUserLoggedIn()) {
    header("Location: admin.php");
    die;
}
if (isset($_POST['date']) && isset($_POST['title']) && isset($_POST['description']) && isset($_POST['price'])) {
    if ($_POST['date'] == "") {
        header("location: admin_corsi.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_corsi.php?msg=emptytitle");
        die;
    }
    $title = htmlentities($_POST['title']);
    $desc = $_POST['description'];
    if ($_POST['price'] == "") {
        header("location: admin_corsi.php?msg=emptyprice");
        die;
    }
    $price = htmlentities($_POST['price']);
    if (dbcontroller::createCorsoMonotematico($date, $title, $desc, $price)) {
        header("location: admin_corsi.php?msg=success");
    } else {
        header("location: admin_corsi.php?msg=errordb");
    }
} else {
    header("location: admin_corsi.php?msg=error");
}