【问题标题】:Check if the user is activate or not检查用户是否激活
【发布时间】:2015-08-26 12:22:09
【问题描述】:

我正在尝试开发一个登录/注册系统,因此用户必须激活其帐户。我的问题是如何在数据库中检查“激活”列,如果未激活,则为 0,如果他/她的帐户处于活动状态,则为 1,另外,如果它不活动,我想放一个以显示消息。

$sql2 = "SELECT * WHERE username2='$username2' AND activation=0";
$result2 = mysql_query($sql2);
if($result2=1){
    echo"Please activate your account"; 
}
else{
    echo " ";
}

【问题讨论】:

  • 你能发布你的代码吗?
  • 你可以使用 where 语句,在参数中你可以输出类似这样的东西 ...activate = '1' 类似的东西
  • 这就是我想使用的,一个选择语句,但我不知道语法,比如使用会话变量用户名选择用户名并检查激活是否为 0 显示“未激活”跨度>

标签: database session login registration


【解决方案1】:

试试这个:

public function function_name ($username){
  $this->db->select('*');
  $this->db->from('table_name'); // table_name where you can find the column username and activation
  $this->db->where(array('username' => $username , 'activate' => 0)); // condition use  if the user is active or not

  $query = $this->db->get();
  return $query->return_array(); // you can also use here first_row('array')

}

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 2016-10-05
    • 2014-11-29
    • 1970-01-01
    相关资源
    最近更新 更多