Example #1
0
File: exam_new.php Project: pta/oes
$db = new Database(DB_HOST, DB_USER, DB_PASS);
$db->selectDatabase(DB_NAME);
if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $time = $_POST['time'];
    $duration = (int) $_POST['duration'];
    $sched_date = $_POST['sched_date'];
    $sched_hour = $_POST['sched_hour'];
    $sched_time = $sched_date . ' ' . $sched_hour . ':00';
    $noq = $_POST['noq'];
    $db->begin();
    try {
        if (($class = $_POST['class']) == 0) {
            $newclass = $_POST['newclass'];
            try {
                $class = $db->insertClass($newclass);
            } catch (Exception $e) {
                echo "<center>Không thể tạo <b>Lớp</b> mới với tên '{$newclass}'.</center>";
                throw $e;
            }
        }
        if (($subject = $_POST['subject']) == 0) {
            $newsubject = $_POST['newsubject'];
            try {
                $subject = $db->insertSubject($newsubject);
            } catch (Exception $e) {
                echo "<center>Không thể tạo <b>Môn</b> mới với tên '{$newsubject}'.</center>";
                throw $e;
            }
        }
        if (($teacher = $_POST['teacher']) == 0) {