用户注册及跟踪代码(一)
用户注册及跟踪代码(一),用户注册及跟踪代码(一)
1. SQL的表及储存过程
---------------------------------------------
CREATE TABLE [dbo].[userbaseinfo] (
[userid] [varchar] (50) NOT NULL ,
[password] [varchar] (50) NOT NULL ,
[validcodelogin] [char] (50) NOT NULL ,
[userlevel] [char] (1) NULL ,
[logintime] [char] (50) NULL
) ON [PRIMARY]
GO
alter table userbaseinfo
add
constraint PK_userbaseinfo_userid
primary key (userid)
Go
CREATE TABLE [dbo].[userdetailinfo] (
[userid] [varchar] (50) NOT NULL ,
[password] [varchar] (30) NOT NULL ,
[realname] [varchar] (10) NULL ,
[sex] [char] (10) NULL ,
[birthday] [datetime] NULL ,
[idcode] [varchar] (50) NULL ,
[address] [varchar] (300) NULL ,
[email] [varchar] (50) NULL ,
[telephone] [varchar] (50) NULL
) ON [PRIMARY]
GO
alter table userdetailinfo
add
constraint PK_userdetailinfo_userid
primary key (userid)
Go
SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
GO
CREATE proc dbo.proc_GetRandom_internal
--取得校验码
@minNum integer,
@maxNum integer,
@RandomNum float output
as
set nocount on
declare @numRange integer
declare @ranSeed integer
declare @curTime datetime
begin
select @numRange=@maxNum-@minNum+1
select @curTime=getdate()
select @ranSeed=datediff(s,'2000-1-1',@curTime)
select @ranSeed=@ranSeed+1
select @RandomNum=rand()*@numRange+@minNum
--print @RandomNum
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_GetValidCode_Internal
--取得校验码
@CodeLength integer,
@ValidCode varchar(10) output
as
set nocount on
declare @chrRnd char(1)
declare @chrRndNo integer
begin
select @ValidCode=""
while (@CodeLength0)
begin
exec proc_GetRandom_internal 1,52,@chrRndNo output
if @chrRndNo26
begin
select @chrRndNo=@chrRndNo+6
end
select @chrRnd=char(@chrRndNo+64)
select @ValidCode=@ValidCode+@chrRnd
select @CodeLength=@CodeLength-1
end
print @validCode
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_UserInfoUpdate
--用户更新个人信息
@ValidCodeLogin varchar(10),
@RealName Varchar(10),
@Sex Varchar(10),
@Birthday datetime,
@IDCode Varchar(50),
@Address Varchar(300),