<!--#include file="inc/config.asp"-->
<!--#include file="inc/md5.asp"-->
<%
ucuser=Replace(Replace(Left(request.Form("ucuser"),20),"<","["),">","]")
Gender=Replace(Replace(Left(request.Form("Gender"),3),"<","["),">","]")
UNature=Replace(Replace(Left(request.Form("UNature"),3),"<","["),">","]")
ucpass1=request.Form("ucpass1")
ucpass2=request.Form("ucpass2")
ucemail=request.Form("ucmail")
agt=request.Form("agt")
if agt="" then
response.Write "<script >alert('提示：\n\n对不起，您没有同意会员服务条款,请同意...');history.back(-1);</script>"
response.end
end if
if ucuser="" then
response.Write "<script >alert('提示：\n\n对不起，用户名没有填写,请填写...');history.back(-1);</script>"
response.end
end if
if ucpass1="" or ucpass2="" then
response.Write "<script >alert('提示：\n\n对不起，密码没有填写,请填写...');history.back(-1);</script>"
response.end
end if
if ucpass1<>ucpass2 then
response.Write "<script >alert('提示：\n\n对不起，密码输入不一致,请输入一致...');history.back(-1);</script>"
response.end
end if
if Gender="" then
response.Write "<script >alert('提示：\n\n对不起，性别没有选择...');history.back(-1);</script>"
response.end
end if
if UNature="" then
response.Write "<script >alert('提示：\n\n对不起，请选择您的性质...');history.back(-1);</script>"
response.end
end if
'开始检查必要数据
'检测用户名是否禁止让注册
set rs=Server.CreateObject("Adodb.Recordset")
	sql="select * from H_err where MyUsererr='"&ucuser&"'"
	rs.open sql,conn,1,1
	if not rs.bof then
	response.Write "<script >alert('提示：\n\n对不起，用户名"&ucuser&"是系统保护注册域名,请更换...');history.back(-1);</script>"
	response.end 
	end if
rs.close
'开始检查用户名是否重复
set rs=Server.CreateObject("Adodb.Recordset")
	sql="select * from H_user where ucuser='"&ucuser&"'"
	rs.open sql,conn,1,1
	if not rs.bof then
	response.Write "<script >alert('提示：\n\n对不起，用户名"&ucuser&"已让注册,请更换...');history.back(-1);</script>"
	response.end 
	end if
rs.close
'开始写入数据
set rs=Server.CreateObject("Adodb.Recordset")
	sql="select * from H_user"
	rs.open sql,conn,1,3
	rs.addnew
	rs("ucuser")=ucuser
	rs("ucpass")=md5(ucpass1)
	rs("ucemail")=ucemail
	rs("UGender")=Gender
	rs("UNature")=UNature
	rs("RDate")=now()
	rs.update
	rs.close
	set rs=nothing	
	'开始生成
	set rs=Server.CreateObject("Adodb.Recordset")
	sql="select * from H_user where ucuser='"&ucuser&"'"
	rs.open sql,conn,1,1
			session("Uid") = rs("id")
			session("ucuser") = rs("ucuser")
	rs.close
		'发送邮件
    if W_mail=1 then
	E_UID=conn.execute("select ID from H_user where ucuser='"&E_user&"'")("ID")
	set rs=Server.CreateObject("Adodb.Recordset")
	sql="select * from H_Message"
	rs.open sql,conn,1,3
	rs.addnew
	rs("UID")=E_UID'发送人ID
	rs("YID")=session("Uid")'收件人ID
	rs("Mtitle")=E_title'标题
	rs("Mchar")=E_Mchar'内容
	rs("Mdu")=0'邮件未读状态
	rs("Rdate")=now()
	rs.update
	rs.close
	set rs=nothing	
	end if
	response.Write "<script >alert('提示：\n\n注册成功\n\n立即登陆...');location.href='user/index.asp';</script>"
	response.End()
%>