gpt4 book ai didi

php - 验证帐户状态

转载 作者:行者123 更新时间:2023-11-29 13:27:00 25 4
gpt4 key购买 nike

我正在尝试检查帐户状态是否已验证。这是通过 Mysql 表中的 ENUM 列完成的。我可以将状态更改为已验证"is",但似乎无法检查它是还是否。我尝试了以下代码的不同方法,但没有成功。提前谢谢大家。

<?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');
}
}
?>

最佳答案

在读数中添加一个条件,如果您的列名称是“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');
}
}

关于php - 验证帐户状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19999745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com