Example #1
0
File: test.php Project: pta/oes
if (!isset($_SESSION['student'])) {
    header("Location: login.php");
}
$student = $_SESSION['student'];
$db = new Database(DB_HOST, DB_USER, DB_PASS);
$db->selectDatabase(DB_NAME);
if (isset($_GET['eid'])) {
    $eid = $_GET['eid'];
    $result = $db->query("select * from oes_Exam where ID = {$eid}");
    $exam = mysql_fetch_array($result);
    mysql_free_result($result);
    $test = $db->openTest($student, $eid);
    if ($test == null) {
        $db->begin();
        try {
            $test = $db->createTest($student, $eid, $exam['Subject'], $exam['NoQ']);
            $db->commit();
        } catch (Exception $e) {
            $db->rollback();
            ?>
					<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head>
					<center>Không thể tạo <b>Bài thi</b> mới.</center>
					<center><button onClick='history.back()'>Trở lại</button></center>
				<?php 
            echo $e->getMessage();
            return -1;
        }
    }
    $_SESSION['test'] = $test;
    header('Location: question.php');
    return;