Example #1
0
<?php

require 'dbadapter.php';
require 'validate.php';
if (isset($_POST['username'])) {
    $error = validateUserLogin();
    if (!$error) {
        // validation successful
        $username = $_POST['username'];
        $result = getUserByName($username);
        $count = mysql_num_rows($result);
        if ($count === 1) {
            // user exists
            $row = mysql_fetch_row($result);
            if (password_verify($_POST['password'], $row[3])) {
                // password verified
                userActive($username);
                // switch active on for user $username
                session_regenerate_id();
                $_SESSION['username'] = $username;
                session_write_close();
                $message = "Welcome {$username}";
                echo "<script type='text/javascript'>alert('{$message}'); window.location.href = 'http://localhost/mates/home.php';</script>";
            } else {
                // wrong password
                $message = "Sorry, the password did not match, please try again.";
                echo "<script type='text/javascript'>alert('{$message}');</script>";
            }
        } else {
            // no user of that username
            $message = "That username does not exist. Please try again or sign up.";
Example #2
0
    unset($_POST);
}
$username = '';
$password = '';
// keep or reset the form fields
if (isset($_POST['username'])) {
    $username = $_POST['username'];
}
if (isset($_POST['password'])) {
    $password = $_POST['password'];
}
$display = true;
if (isset($_POST['submit'])) {
    unset($_POST['submit']);
    $user_id = "";
    if (validateUserLogin($err_msg)) {
        $conn = new dbAccess($debug);
        if (($rc = $conn->dbLoginUser($username, $password, $user_id)) == GOOD_RC) {
            // we have a valid user
            // Create new session, store the user id
            $_SESSION['user_id'] = $user_id;
            $sess_id = session_id();
            $_SESSION['sess_id'] = $sess_id;
            $dom = new DomDocument();
            $dom->validateOnParse = true;
            $el = $dom->getElementById('sess_id');
            $el->nodeValue = $sess_id;
            $uid = $dom->getElementById('user_id');
            $uid->nodeValue = $user_id;
            // Redirect to user info page
            ob_end_clean();
Example #3
0
 <?php 
require 'dbConn.php';
session_start();
/*
	userType in session
	1- RESIDENCE_DIRECTOR
	2- RESIDENCE_ASSISTANT
	3- STUDENT
*/
if (isset($_POST["funct"]) && !empty($_POST["funct"])) {
    if ($_POST["funct"] == "VALUSER") {
        validateUserLogin();
    } else {
        if ($_POST["funct"] == "HOUSINGAPPLICATION") {
            submitHousingApplication();
        } else {
            if ($_POST["funct"] == "BEGININGHOUSINGAPPLICATION") {
                submitBeginingHousingApplication();
            } else {
                if ($_POST["funct"] == "ROOMSELECTIONFORM") {
                    submitRoomSelectionForm();
                } else {
                    if ($_POST["funct"] == "RETRIEVEFLOORS") {
                        retrieveFloors();
                    } else {
                        if ($_POST["funct"] == "RETRIEVESUITES") {
                            retrieveSuites();
                        } else {
                            if ($_POST["funct"] == "RETRIEVEROOMS") {
                                retrieveRooms();
                            } else {