User register and confirm the online ASP program.
1. SQL table and storage process
---------------------------------------------
CREATE TABLE [dbo]. [Userbaseinfo] (
[UserID] [varchar] () not NULL,
[Password] [varchar] () not NULL,
[Validcodelogin] [Char] () not NULL,
[Userlevel] [Char] (1) NULL,
[Logintime] [Char] (m) NULL
) on [PRIMARY]
Go
ALTER TABLE Userbaseinfo
Add
Constraint Pk_userbaseinfo_userid
Primary KEY (UserID)
Go
Begin
exec proc_isuservalidbycode_internal @ValidCodeLogin, @UserValidFlag output
If @UserValidFlag <0
Begin
--select @UserValidFlag as ResultId
---1 users are not logged in
---2 User timeout
Return @UserValidFlag
End
Select @UserID =userid from Userbaseinfo where validcodelogin= @ValidCodeLogin
Update Userdetailinfo
Set Realname= @RealName,
Sex= @Sex,
Birthday= @Birthday,
Idcode= @IDCode,
Address= @Address,
Email= @eMail,
Telephone= @Telephone
where
Userid= @UserID;
if (@RealName = "" or @Birthday = "" or @Sex = "" or @IDCode = "" or @Address = "" or @eMail = "" or @Telephone = ")
Begin
--select-3 as ResultId
Return-3--Information not fully completed
End
Select 0 as ResultId
End
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER ON
Go
SET ANSI_NULLS on
Go
Create proc Dbo.proc_userlogout
--User exits
@ValidCodeLogin varchar (10)
As
SET NOCOUNT ON
DECLARE @UserValidFlag int
DECLARE @UserLevel varchar (9)
Begin
exec proc_isuservalidbycode_internal @ValidCodeLogin, @UserValidFlag output
if (@UserValidFlag <0)
Begin
--select @UserValidFlag as ResultId
Return @UserValidFlag
---1 users are not logged in
---2 User timeout
End
Update Userbaseinfo
Set validcodelogin= ',
Logintime= ' 1970-1-1 '
where
validcodelogin= @ValidCodeLogin
--select 0 as ResultId
return 0
End
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
CREATE proc Dbo.proc_userregbase
--User basic information registration
@UserID Varchar (30),
@Password Varchar (30)
As
Begin
Select @UserLevel = "0"
Select @PwdLength =4
if (datalength (@Password) < @PwdLength)
Begin
Select-4 as Returnid
Return-4--The password length is not enough
End
--exec proc_getvalidcode_internal, @ValidCodeReg output--Obtain user registration checksum code
exec proc_getvalidcode_internal, @ValidCodeLogin output--Get user Login Check code
exec proc_isuserexist_internal @UserID, @userExist output-get user presence Mark
Select @LoginTime =getdate ()
Print @userExist
If @userExist =0
Begin
Select-1 as ResultId
Return-1--User already exists
End
--Insert User profile table
INSERT INTO Userbaseinfo
(Userid,password,userlevel,validcodelogin,logintime)
Values (@UserID, @Password, @UserLevel, @ValidCodeLogin, @LoginTime)
--Insert User Details table
INSERT INTO Userdetailinfo
(Userid,password) Values (@UserID, @Password)
--Obtain user registration check code, login check code
Select 0 as ResultId
Select Validcodelogin from Userbaseinfo where userid= @UserID
return 0
End
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
Create proc Dbo.proc_isuserexist_internal
--Determine if the user name exists
@UserID Varchar (30),
@existFlag int Output
As
SET NOCOUNT ON
Begin
If not EXISTS (SELECT * from Userbaseinfo where userid= @UserID)
Begin
Select @existFlag =-1
Return
End
Select @existFlag =0
Return
End
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
Create proc Dbo.proc_isuservalidbycode_internal
--user identity verification (based on login check code)
@ValidCodeLogin varchar (10),
@validFlag int Output
As
Begin
If not EXISTS (SELECT * from Userbaseinfo where validcodelogin= @ValidCodeLogin)
Begin
Select @validFlag =-1-User not logged in
Return
End
Select @LoginTime = (select Logintime from Userbaseinfo where validcodelogin= @ValidCodeLogin)
Select @curTime =getdate ()
Select @diffTime =datediff (hh, @LoginTime, @curTime)
If @diffTime >=10
Begin
Select @validFlag =-2-user timeout
Return
End
Select @LoginTime =getdate ()--Obtaining the user's last logon time
Update Userbaseinfo set logintime= @LoginTime where validcodelogin= @ValidCodeLogin
Select @validFlag =0
Return
End
Go
SET QUOTED_IDENTIFIER OFF
Go
SET ANSI_NULLS on
Go
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.