Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cesanet/
Upload File :
Current File : /var/www/cesa.co.za/cesanet/login.php

<?php
include_once("inc_functions.php");

if (!empty($_POST["username"]) && !empty($_POST["password"])) {
    $sql = "SELECT * FROM CCEStudents "
            . "WHERE WebUsername='" . $_POST["username"] . "' AND WebPassword='" . $_POST["password"] . "' "
            . "AND Accepted=1 AND Cancelled=0 AND BlockAccess='n'";
    $recStudents = mysql_query($sql);

    // echo $sql;
    // exit;

    if ($rowStudents = mysql_fetch_assoc($recStudents)) {
        $_SESSION["StudentID"] = $rowStudents["CCEStudentID"];
        $_SESSION["StudentFullName"] = $rowStudents["FirstName"] . " " . $rowStudents["Surname"];
        $_SESSION["StudentEmail"] = $rowStudents["EmailAddress"];
        $_SESSION["ModulesEnrolled"] = $rowStudents["ModulesEnrolled"];
        if ($rowStudents["Archived"] == 1) {
            $sql = "SELECT YEAR(StartDate) AS StudentYear "
                    . "FROM `CCEStudentCourses` "
                    . "INNER JOIN `CCECourseSchedules` ON `CCEStudentCourses`.`CCECourseScheduleID` = `CCECourseSchedules`.`CCECourseScheduleID` "
                    . "WHERE CCEStudentID = " . $_SESSION["StudentID"];
        //    echo $sql;
        //    exit;
            $recYear = mysql_query($sql);
            if ($rowYear = mysql_fetch_assoc($recYear)) {
                $_SESSION["StudentYear"] = $rowYear["StudentYear"];
            } else {
                $_SESSION["StudentYear"] = date('Y') - 1;
            }
            header("Location: /cesanet/calendar.php");
        } else {
            $_SESSION["StudentYear"] = 0;
            header("Location: /cesanet/calendar.php");
        }
    } else {
        $sMsg = "Invalid username and/or password.";
    }

    mysql_free_result($recStudents);
}

include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_begin.php");
?>
<h1> Login</h1>
<?php
if (isset($sMsg) && !empty($sMsg))
    echo "<span class='errmsg'>" . $sMsg . "</span>";
?>
<form id="form1" name="form1" method="post" action="/cesanet/login.php">
    <table border="0" cellspacing="0" cellpadding="5">
        <tr>
            <td>Username:</td>
            <td><label>
                    <input type="text" name="username" id="username" />
                </label></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><label>
                    <input type="password" name="password" id="password" />
                </label></td>
        </tr>
        <tr>
            <td><label>
                    <input type="submit" name="button" id="button" value="Submit" />
                </label></td>
            <td>&nbsp;</td>
        </tr>
    </table>
</form>
<p><a href="forgotpwd.php">Have you forgotten your password?</a></p>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_end.php");