function postmail($to, $resetpasswordurl)
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Host = 'smtp.163.com';
    $mail->Port = 25;
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->SetFrom('*****@*****.**', 'Website OfCourse');
    $mail->Subject = 'Retrieve Password to Website OfCourse';
    $mail->MsgHTML('<p>This email is sent automatically from website OfCourse.</p> 
    	<p>To reset your password please <a href="' . $resetpasswordurl . '"><B>Click Here</B></a>.</p>');
    $address = $to;
    $mail->AddAddress($address, '');
    if (!$mail->Send()) {
        callerror('failed to send email', '../');
        exit;
    }
}
}
$results = $s->fetchAll();
if (isset($_POST['delete'])) {
    try {
        $sql = 'DELETE FROM notice WHERE id = :id';
        $s = $pdo->prepare($sql);
        $s->bindValue(':id', $_POST['noticeid']);
        $s->execute();
    } catch (PDOException $e) {
        callerror('database error', '../');
        exit;
    }
    header('Location:.');
}
if (isset($_POST['add'])) {
    try {
        $sql = 'INSERT INTO notice SET
			courseid = :courseid,
			outdate = CURDATE(),
			content = :content';
        $s = $pdo->prepare($sql);
        $s->bindValue(':courseid', $_SESSION['courseid']);
        $s->bindValue(':content', $_POST['addnotice']);
        $s->execute();
    } catch (PDOException $e) {
        callerror('database error', '../');
        exit;
    }
    header('Location:.');
}
include './coursenoticeform.html.php';
            exit;
        }
    }
    header('Location:.');
}
if (isset($_POST['download'])) {
    try {
        $sql = 'SELECT * FROM resource WHERE id = :id';
        $s = $pdo->prepare($sql);
        $s->bindValue(':id', $_POST['id']);
        $s->execute();
    } catch (PDOException $e) {
        callerror('database error', '../');
        exit;
    }
    $file = $s->fetch();
    if (empty($file)) {
        callerror('file not found in database', '../');
        exit;
    } else {
        $filename = $file['name'];
        $filedata = file_get_contents($file['addr']);
        $mimetype = $file['type'];
        $disposition = 'attachment';
        header('Content-length: ' . strlen($filedata));
        header("Content-type: {$mimetype}");
        header("Content-disposition: {$disposition}; filename={$filename}");
        echo $filedata;
    }
}
include './courseresourceform.html.php';
<?php

require_once '../includes/helpers.inc.php';
callerror('you have no privilege for this page', '../');
exit;
}
try {
    $sql = 'SELECT * FROM quiz WHERE id = :id';
    $s = $pdo->prepare($sql);
    $s->bindValue(':id', $_GET['id']);
    $s->execute();
} catch (PDOException $e) {
    callerror('database error', '../');
    exit;
}
$result = $s->fetch();
$oldqlist = json_decode($result['jsonq'], true);
$oldalist = json_decode($result['jsona'], true);
$tempalist = json_decode(base64_decode($_GET['tempa']), true);
$correct = 0;
$colorarray = array();
for ($i = 1; $i <= count($oldalist); $i++) {
    if ($oldalist[$i] == $tempalist[$i]) {
        $correct++;
        $colorarray[$i] = '#5CB85C';
    } else {
        $colorarray[$i] = '#D9534F';
    }
}
$correct = round($correct / count($oldalist) * 100) . '%';
$pagetitle = $result['title'] . ' : ' . $correct . ' Correct';
if (empty($oldqlist) or empty($oldalist) or empty($tempalist)) {
    callerror('incomplete information', '../');
    exit;
}
include './quizshowanswerform.html.php';
        $s->bindValue(':title', $_POST['title']);
        $s->bindValue(':startline', $_POST['startline']);
        $s->bindValue(':deadline', $_POST['deadline']);
        $s->bindValue(':content', $_POST['content']);
        $s->bindValue(':name', $tempname);
        $s->bindValue(':type', $temptype);
        $s->bindValue(':addr', $tempaddr);
        $s->bindValue(':id', $_GET['id']);
        $s->execute();
    } catch (PDOException $e) {
        callerror('database error', './');
        exit;
    }
    header('Location:.?id=' . $_GET['id']);
}
if (isset($_POST['repdownload'])) {
    if (!file_exists($_POST['repaddr'])) {
        callerror('file do not exist', './');
        exit;
    } else {
        $filename = $_POST['repname'];
        $filedata = file_get_contents($_POST['repaddr']);
        $mimetype = $_POST['reptype'];
        $disposition = 'attachment';
        header('Content-length: ' . strlen($filedata));
        header("Content-type: {$mimetype}");
        header("Content-disposition: {$disposition}; filename={$filename}");
        echo $filedata;
    }
}
include './courseassignmentcheckform.html.php';
            } else {
                $welcometag = 'Welcome, ' . $_SESSION['useridentity'] . ' ' . $_SESSION['usertag'];
            }
        }
    }
}
try {
    $sql = 'SELECT * FROM quiz WHERE id = :id';
    $s = $pdo->prepare($sql);
    $s->bindValue(':id', $_GET['id']);
    $s->execute();
} catch (PDOException $e) {
    callerror('database error', '../');
    exit;
}
$result = $s->fetch();
$pagetitle = $result['title'];
$oldqlist = json_decode($result['jsonq'], true);
if (empty($oldqlist)) {
    callerror('no question added', '../');
    exit;
}
if (isset($_POST['save'])) {
    $ajson = array();
    for ($i = 1; $i <= count($oldqlist); $i++) {
        $ajson[$i] = implode(';', $_POST['c' . $i]);
    }
    $jsona = json_encode($ajson);
    header('Location:../quizshowanswer?id=' . $_GET['id'] . '&tempa=' . base64_encode($jsona));
}
include './quizanswerform.html.php';