declare @service_deadline_date smalldatetime,@community_setting_max_online_count int ---定義一個(gè)變量為 短日期格式
select @community_setting_max_online_count=community_setting_max_online_count,@service_deadline_date=service_deadline_date from community_info where community_id=@community_id --這里是求最大登錄人數(shù)
if datediff(d,@service_deadline_date,getdate())>10 --其實(shí)這個(gè)是限制用戶的使用期,求當(dāng)前日期與庫(kù)中的記錄日期如時(shí)大于10天,則返回@result =11 begin set @result=11 --超過(guò)使用期 return end
if (select count(*) from online_user where =@community_setting_max_online_count">community_id=@community_id)>=@community_setting_max_online_count --根據(jù)庫(kù)中的記錄設(shè)定與當(dāng)前人數(shù)比較 begin set @result=10 --超出在線人數(shù)限制 --返回@result=10 return end
declare @stamia int,@last_update_stamia_date smalldatetime,@level_id int --定義變量 整型 短日期型 整型 declare @userid int ,@user_role int select @userid=userid,@user_role=user_role,@stamia=stamia,@last_update_stamia_date=last_update_stamia_date,@level_id=level_id from user_info where username=@username and password=@password and community_id=@community_id and user_type=0
--從用戶信息表中,將一些信息寫(xiě)入到定義的三個(gè)變量中
if @userid is not null ----如果@userid 不變null值 begin --用戶名和密碼校驗(yàn)成功 set @result=1 --檢驗(yàn)成功 return end else begin set @result=0 ---登錄失敗 end
set nocount OFF
GO
我們給上面的過(guò)程取個(gè)名login_verify叫做
寫(xiě)成是ASP代碼中調(diào)用安全認(rèn)證的地方
'''事先已經(jīng)定義好conn
Set cmd.ActiveConnection=conn cmd.CommandText="login_verify" cmd.CommandType=&H0004
@community_id int, --拿值 @username varchar(20), @password varchar(40), @result int