コード例 #1
0
 */
require_once './controller/QuestionCtrl.php';
require_once './model/Question.php';
//
//echo '<br><br><br><br>';
//foreach ($_POST as $key => $value) {
//    echo $key.': '.$value.'<br>';
//}
$type = $_POST['type'];
$cate = htmlspecialchars($_POST['cate']);
$point = htmlspecialchars($_POST['point']);
$title = htmlspecialchars($_POST['title']);
$explain = htmlspecialchars($_POST['explain']);
if ($type == 'add') {
    $q_tmp = new Question($cate, $point, $title, $explain);
    $qid = QuestionCtrl::addQuestion($q_tmp);
} else {
    if ($type == 'update') {
        $qid = htmlspecialchars($_POST['qid']);
        $q_tmp = QuestionCtrl::get($qid);
        if ($title != '') {
            $q_tmp->setTitle($title);
        }
        if ($explain != '') {
            $q_tmp->setExplain($explain);
        }
        $q_tmp->setId($qid);
        QuestionCtrl::updateQuestion($q_tmp);
    }
}
if ($qid > 0) {