<!--#include file="conn.asp"-->
<!--#include file="admin/config.asp"-->
<!--#include file="admin/inc/char.asp"-->
<%dim usr,pwd,pwd2,email,qq,icq,msn,homepage
usr=Trim(Request.Form("usr"))
pwd=Trim(Request.Form("pwd"))
pwd2=Trim(Request.Form("pwd2"))
email=Trim(Request.Form("email"))
qq=Trim(Request.Form("qq"))
icq=Trim(Request.Form("icq"))
msn=Trim(Request.Form("msn"))
homepage=Trim(Request.Form("homepage"))

dim sql,rs,errmsg,founderr
founderr=false

if SiteSetting(7)="no" or SiteSetting(8)="no" then
	founderr=true
	errmsg=errmsg+"<li>暂停注册</li>"
end if

if usr="" then
	founderr=true
	errmsg=errmsg+"<li>用户名不能为空</li>"
elseif strlen(usr)<3 or strlen(usr)>10 then
	founderr=true
	errmsg=errmsg+"<li>用户名应为3～10个字符</li>"
else
	sql="select top 1 id from UserInfo where USR='"&usr&"'"
	set rs=conn.execute(sql)
	if not (rs.eof and rs.bof) then
		founderr=true
		errmsg=errmsg+"<li>用户名已存在</li>"
		set rs=nothing
	end if
end if

if pwd="" or pwd2="" then
	founderr=true
	errmsg=errmsg+"<li>密码不能为空</li>"
elseif strlen(pwd)<4 or strlen(pwd)>20 then
	founderr=true
	errmsg=errmsg+"<li>密码长度应为4～20个字符</li>"
elseif pwd<>pwd2 then
	founderr=true
	errmsg=errmsg+"<li>两次输入的密码不一致</li>"
end if

if Email="" then
	founderr=true
	errmsg=errmsg+"<li>E-mail不能为空</li>"
elseif IsValidEmail(Email)=false then
	founderr=true
	errmsg=errmsg+"<li>E-mail地址格式不正确</li>"
end if

if qq<>"" and isInteger(qq)=false then
	founderr=true
	errmsg=errmsg+"<li>QQ号码必须是数字</li>"
end if

if icq<>"" and isInteger(icq)=false then
	founderr=true
	errmsg=errmsg+"<li>ICQ号码必须是数字</li>"
end if

if msn<>"" and IsValidEmail(msn)=false then
	founderr=true
	errmsg=errmsg+"<li>MSN格式不正确</li>"
end if

if founderr=false then
	conn.execute("insert into UserInfo (USR,PWD,Email,QQ,ICQ,MSN,Homepage,Point,Power,IsAdmin) values ('"&usr&"','"&pwd&"','"&email&"','"&qq&"','"&icq&"','"&msn&"','"&homepage&"',"&cint(RegPoint)&",'1,0,0,0,0,0',false)")
	dim gourl,msg
	gourl="default.asp"
	msg="会员注册成功！"
	call ok()
else
	call error()
end if

conn.close
set conn=nothing
%>