使用MYSQLi检查数据库中是否存在用户名/激活了用户名 [英] Check if username exist/activated in database using MYSQLi

查看:216
本文介绍了使用MYSQLi检查数据库中是否存在用户名/激活了用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$username = mysqli_real_escape_string($_POST['username']);

$result = mysqli_query($connect, "SELECT * FROM account WHERE username='".$username."' AND activate='0'");

while($row = mysqli_fetch_assoc($result)) {
    echo 'Account not activated.';
}

我是MYSQLi的新手,如果用户输入错误的用户名并且未激活用户名,我需要如何显示错误的帮助.到目前为止,我已经收到了上面的代码.

I'm new to MYSQLi and I need help on how do I show an error if the user enter a wrong username and its not activated. So far I got the code above.

推荐答案

尝试一下

  $username = mysqli_real_escape_string($_POST['username']);

  $result = mysqli_query($connect, "SELECT * FROM account WHERE username='".$username."' AND activate='0'");

  if ($result->num_rows) {
echo "you are activated !!";
                          } 

   else
  {
  // do what u like here if not activated
    }

这篇关于使用MYSQLi检查数据库中是否存在用户名/激活了用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆