示例#1
0
<?php

require_once './includes/configuration.php';
require_once './student/student_controller.php';
$display_message = FALSE;
$sc = new Student_controller();
if (isset($_POST['login'])) {
    $user = sanitize_text($_POST['user']);
    $pass = sanitize_text($_POST['pass']);
    $error_msg;
    if ($sc->validate_username($user) !== 1 || $sc->validate_password($pass) === FALSE) {
        $error_msg = "Invalid username or password";
        $display_message;
    } else {
        $answer = $sc->log_member_in($user, $pass);
        if ($answer !== FALSE && $answer !== TRUE) {
            $display_message = TRUE;
        } elseif ($answer === FALSE) {
            $display_message = TRUE;
        }
    }
    if (isset($_SESSION['logged_in'])) {
        if (!empty($_SESSION['tried_url'])) {
            $tried_url = $_SESSION['tried_url'];
            $_SESSION['tried_url'] = null;
            ?>
			<script>window.location = "<?php 
            echo $tried_url;
            ?>
";</script>
			<?php