dongzhi8487 2019-07-04 14:49
浏览 78

当您进入登录页面时,如何修复我的激活流体回显“帐户已暂停”

Im coding a php chat and I recently added activated field. It works right but the error message displays 24/7.

I have tried the else tag, used 'no' in activated tabel, redefined it to the $result.

$result = mysqli_query($conn , "SELECT * from user where email='$email' and password='$password' and activated = 'yes' ");
while($row = mysqli_fetch_assoc($result))
{
    $_SESSION['email'] = $row['email'];
    $_SESSION['password'] = $row['password'];
    $_SESSION['name'] = $row['name'];
}
if(mysqli_num_rows($result)>0){         
    $query = mysqli_query($conn, "UPDATE user SET status = 'Online' WHERE email = '$email' ");
    header('location: index.php');
}
else {
    echo "<font color='red'><p align='center'>Incorrect Email or Password</p>";
}   
$activated = $result;
if($activated == 'yes'){

} else {
    //This is the Activated Error that's not working.
    echo "<font color='red'><p align='center'>Your Account Has Been Suspended</p>";
}

I want the error message to only display if the users account is suspended, but the result I get is the message displays to all users and there accounts are not suspended.

  • 写回答

1条回答 默认 最新

  • duanlianyun0462 2019-07-04 14:57
    关注

    Your SQL is only loading records where activated = 'Yes', so do you even need this check?

    $result is the resultset of your query, which will never equal 'Yes'.

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?