<!--#include file="conn.asp"-->
<!--#include file="err.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="dengji.asp"-->
<%
dim userid,yearold,userpsd,userpsd2,usermail,userques,userans,sex
userid=trim(request("userid"))
yearold=trim(request("yearold"))
userpsd=trim(request("userpsd"))
userpsd2=trim(request("userpsd2"))
usermail=trim(request("usermail"))
userques=trim(request("userques"))
userans=trim(request("userans"))
comurl=trim(request("url"))
sex=trim(request("sex"))

if chkdomain(userid)=false then
errma "注册没有成功","用户名只能使用字母，数字及下划线！"
response.End()
elseif len(userid)>10 then
errma "注册没有成功","用户名不允许大于10字符" 
response.End()
elseif len(userpsd)>12 or len(userpsd)<6 then
errma "注册没有成功","密码不允许大于12,小于6字符" 
response.End()
elseif  userpsd<>userpsd2 then
errma "注册没有成功","两次密码不一样" 
response.End()
elseif Not IsNumeric(yearold) then
errma "注册没有成功","年龄么当然要填数字。" 
response.End()
elseif yearold>100 or yearold<1 then
errma "注册没有成功","您的年龄不对嘛!" 
response.End()
elseif instr(usermail,"@")<=0 or instr(usermail,".")<=0 then
errma "注册没有成功","E-Mail格式不对" 
response.End()
end if

dim rs,sql
if request.Cookies("kwreg")="" then
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_user where username='"&userid&"'"
rs.open sql,conn,1,3
   if rs.recordcount>=1 then
    errma "注册没有成功","用户名已经被占用!"
    response.End()
   end if
   rs.addnew
   rs("username")=userid
   rs("userpass")=md5(userpsd,16)
   rs("sex")=sex
   rs("jifen")=50
   rs("regtime")=now()
   rs("dengji")=dengji1
   rs.update
   rs.close
   set rs=nothing
   closedb

response.Cookies("kwreg")=userid
Response.Cookies("kwreg").Expires=Date+1
session("userid")=userid
session("usertx")=dengji1
response.write "<script language=javascript>alert('恭喜你,注册成功！');document.location.href='"&comurl&"'</script>"
else
errma "注册没有成功","请明天再注册吧！" 
end if
%>
