$list = $_POST['courses'];
//if the list is empty, then create the array to compare
if ($list == NULL) {
    $list = array();
}
$deleteList = array_diff($lastSelectedCourses, $list);
foreach ($deleteList as $CID) {
    deleteCourse($CID);
}
$insertList = array_diff($list, $lastSelectedCourses);
//update track
updateTrack($MID);
$alladded = True;
foreach ($insertList as $CID) {
    //print "insert" . $CID;
    if (checkReg($CID)) {
        addCourse($CID);
    } else {
        $alladded = False;
    }
}
if ($alladded) {
    $errmsg_arr[] = 'Changes successfully made!!<br>
	<a href="schedule.php?id=' . $MID . '" style="font-size:14px; text-transform: uppercase;">Click to view changes in your <b>degree outlook<b></a>';
    $errflag = true;
}
if ($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: ../addCourses.php");
    $mysqli->close();
Exemple #2
0
$DBmain->query('SET NAMES "utf8"; ');
$DBmain->query('SET CHARACTER SET "utf8"; ');
$DBmain->query('SET character_set_result = "utf8"; ');
$DBmain->query('SET character_set_client = "utf8"; ');
$DBmain->query('SET character_set_connection = "utf8"; ');
$DBmain->query('SET character_set_database = "utf8"; ');
$DBmain->query('SET character_set_server = "utf8"; ');
$throw = array("/regist.php", "/root.php");
// check if login & is login correct or not
if (isset($_SESSION['loginID']) && isset($_SESSION['loginToken'])) {
    if (!checkExist($DBmain, $_SESSION['loginID'], $_SESSION['loginToken'])) {
        locate($URLPv . "logout.php");
    }
    // check regist or not
    $skip = false;
    if (!checkReg($DBmain, $_SESSION['loginID'])) {
        for ($i = 0; $i < count($throw); $i++) {
            if ($throw[$i] == $URI) {
                $skip = true;
            }
        }
        if ($skip == false) {
            locate($URLPv . "regist.php");
        }
    }
}
function needLogin($DBlink)
{
    if (!isset($_SESSION['loginID']) || !isset($_SESSION['loginToken'])) {
        alert('Please login first. ');
        locate($URLPv . "login.php");
Exemple #3
0
<?php

include 'function.php';
$result = [];
if (isset($_POST)) {
    $body = file_get_contents('php://input');
    $data = json_decode($body, true);
    $result = checkReg($data);
}
header('Content-Type: application/json');
echo json_encode($result);