语法错误意外结束文件

时间:2017-07-01 11:37:06

标签: php mysql

我是PHP和堆栈的新手,我找不到其他人遇到同样的问题。

我尝试使用管理员权限登录系统。其中一项权限是能够在网站上注册更多管理员。

当用户通过登录表单登录时,我希望它首先检查我的数据库管理员表中的详细信息,然后检查用户表是否搜索不成功。

我在包含文件中完成了此操作。我开始只使用普通用户,工作正常,我现在尝试合并管理功能。现在它返回错误:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\project\includes\loginAdmin.inc.php on line 121

我检查了代码,一切似乎都很好,数据库连接很好,我似乎无法找到语法错​​误。我是愚蠢的,没有看到明显的东西吗?

这是返回错误的文件:

<?php

session_start();

if (isset($_POST['submit'])) {

include 'dbh.inc.php';

$auid = mysqli_real_escape_string($conn, $_POST['uid']);
$apwd = mysqli_real_escape_string($conn, $_POST['pwd']);

//Error Handlers

//Check if inputs are empty

if (empty($auid) || empty($apwd)) {

    header("Location: ../index.php?login=error");
    exit();

} else {
    $sql = "SELECT * FROM admins WHERE admin_uid='$uid' OR admin_email='$uid'";
    $result = mysqli_query($conn, $sql);
    $resultCheck = mysqli_num_rows($result);

    if ($resultCheck < 1) {
        header("Location: ../index.php?login=error");
        exit();

    } else {

        if ($row = mysqli_fetch_assoc($result)) {

            //De-hashing password

            $hashedPwdCheck = password_verify($pwd, $row['admin_pwd']);

            if ($hashedPwdCheck == false){

                header("Location: ../index.php?login=error");
                exit();

            } elseif ($hashedPwdCheck == true) {

                //Log in the user

                $_SESSION['a_id'] = $row['admin_id'];
                $_SESSION['a_first'] = $row['admin_first'];
                $_SESSION['a_last'] = $row['admin_last'];
                $_SESSION['a_iemail'] = $row['admin_email'];
                $_SESSION['a_uid'] = $row['admin_uid'];

                header("Location: ../index.php?login=success");
                exit();
            }
        }
    }
}

} else {

if (isset($_POST['submit'])) {

include 'dbh.inc.php';

$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);

//Error Handlers

//Check if inputs are empty

if (empty($uid) || empty($pwd)) {

    header("Location: ../index.php?login=error");
    exit();

} else {
    $sql = "SELECT * FROM users WHERE user_uid='$uid' OR user_email='$uid'";
    $result = mysqli_query($conn, $sql);
    $resultCheck = mysqli_num_rows($result);

    if ($resultCheck < 1) {
        header("Location: ../index.php?login=error");
        exit();

    } else {

        if ($row = mysqli_fetch_assoc($result)) {

            //De-hashing password

            $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);

            if ($hashedPwdCheck == false){

                header("Location: ../index.php?login=error");
                exit();

            } elseif ($hashedPwdCheck == true) {

                //Log in the user

                $_SESSION['u_id'] = $row['user_id'];
                $_SESSION['u_first'] = $row['user_first'];
                $_SESSION['u_last'] = $row['user_last'];
                $_SESSION['u_iemail'] = $row['user_email'];
                $_SESSION['u_uid'] = $row['user_uid'];

                header("Location: ../index.php?login=success");
                exit();
            }
        }
    }
}

} else {

header("Location: ../index.php?login=error");
exit();
}

谢谢,对不起,如果这是一个烦人的noob错误。

0 个答案:

没有答案