启用和禁用用户帐户 [英] Enable and disable user accounts

查看:106
本文介绍了启用和禁用用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我在数据库中有一个简单的表.其中包含用户帐户信息.

userid,密码,FirstName,LastName,地址

我想禁用并启用它..以便当我禁用它时..帐户持有人无法登录,而当我启用它时..然后他可以登录.

Hi!
I have a simple table in the database. which have the user account information.

userid , password, FirstName , LastName ,Address

i want to disable and enable it.. so that when i disable it.. account holder can''t be able to login and when i enable it.. then he can login.

推荐答案

为此,您需要更改包含用户详细信息的表,
您需要再添加一个列名(如status)并输入bit并将其设置为默认值1

在这里,当状态为1时,表示用户处于活动状态,表示他/她可以登录;或者,在禁用状态时,将其设置为0,则表示该用户无法登录..

要应用此机制,您可以像这样在用户登录查询中添加一个条件

SELECT * FROM USERDETAIL,其中USERNAME = @USERNAME和密码= @PASSORD AND STATUS = 1

如果它将返回记录,则用户将通过身份验证,否则未通过..

用于禁用用户,您可以触发这样的查询

UPDATE USERDETAIL SET STATUS = 0 WHERE USERNAME = @USERNAME
For this you need to change your table that will contains user detail,
you need to add one more column name like status and type bit and set it with default value 1

here when status is 1 then the user is active means he/she can login, or when you deactivate means set it with 0 then that use can not login..

for apply this mechanism you can add one condition at your user login query like this

SELECT * FROM USERDETAIL WHERE USERNAME = @USERNAME AND PASSWORD = @PASSORD AND STATUS = 1

if it will return record then the user will authenticated else it is not..

for disabling user you can fire a query like this

UPDATE USERDETAIL SET STATUS = 0 WHERE USERNAME = @USERNAME


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