Ejemplo n.º 1
0
<?php

if (isset($_POST["submit"])) {
    require_once "../models/connection.php";
    require_once "../controllers/miscfunction.php";
    require_once "../controllers/notifications.php";
    $username = $_POST["username"];
    $password = $_POST["password"];
    $con = new Connection();
    $connection = $con->getConnection();
    $misc = new MiscFunction($connection);
    $notifyObject = new Notifications();
    $loginValues = array("username" => $username, "password" => $password);
    $_SESSION["loginValues"] = $loginValues;
    $validateLogin = $misc->validateLogin($username, $password);
    if ($validateLogin === false) {
        header("location:./views/login.php");
    }
    $result = $misc->getAdminDetails($username, $password);
    if (mysqli_num_rows($result) == 1) {
        while ($row = $result->fetch_assoc()) {
            $status = $row["status"];
            if ($status == 0) {
                $msg = "You are not allowed to access this page because you have been deacvtivated!!!";
                echo $notifyObject->errorMessage($msg);
                exit;
            }
            $_SESSION["name"] = $row["name"];
            $_SESSION["level"] = $row["level"];
            $level = $row["level"];
            $_SESSION["Admin_Id"] = $row["admin_id"];