0

我正在尝试检查帐户状态是否已验证。这是通过 Mysql 表中的 ENUM 列完成的。我已经能够将状态更改为已验证的“是”,但似乎无法检查它是“是”还是“否”。我尝试了以下代码的不同方式,但无济于事。提前谢谢大家。

<?php
ob_start();
session_start();
include '/home/wc002/include/dbconnect.php';

if (isset($_POST)) {
    $username  = strip_tags(trim($_POST['myusername']));
    $password = strip_tags(trim($_POST['mypassword']));
    $username = mysqli_real_escape_string($conn, $username);

    // Register $myusername, $mypassword
    $_SESSION["myusername"] = $username;
    $_SESSION["mypassword"] = $password;

    //Check if account is Verified
    //$query ="SELECT Verified FROM Member WHERE Verified = false;";
    //$check = mysqli_query($conn, $query);

    //if ($check == true){
    //  echo "Please Verfiy your account";
    //}
    //else{

    //Check username matches
    $query1="SELECT `Password`, `salt` FROM `Member` WHERE `Username`='$username'";
    $result1 = mysqli_query($conn, $query1);

    if(mysqli_num_rows($result1) == 0) // User not found. So, redirect to TwitchMain.php   again.
    {
        die(header("location:TwitchMain.php?loginFailed=true&reason=blank"));
    }

    $userData = mysqli_fetch_array($result1, MYSQL_ASSOC);
    $hash = hash('sha256', $userData['salt'] . hash('sha256', $password));

    //Incorrect password. So, redirect to TwitcMain.php again.
    if($hash != $userData['Password']) 
    {
        die(header("location:TwitchMain.php?loginFailed=true&reason=password"));
    } else { 
   // Redirect to home page after successful login.
        header('Location: Twitch.php');
    }
}
?>
4

1 回答 1

1

为您的读数添加一个条件,如果您的列名是“ENUM”,则在成功后检查 if ($userData['ENUM'] == 1)。

   if($hash != $userData['Password']) 
    {
        die(header("location:TwitchMain.php?loginFailed=true&reason=password"));
    } else { 
   // Redirect to home page after successful login.
        if ($userData['Verified'] == 'YES'){
            header('Location: Twitch.php');
        } else {
            die('account not activated');
        }
    }
于 2013-11-15T11:15:48.890 回答