<!--#include file="../inc/config.asp" -->
<!--#include file="../inc/conn.asp" -->
<!--#include file="../inc/function.asp" -->
<!--#include file="../inc/sql_filter.asp" -->
<!--#include file="../inc/md5.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员注册-<%=SiteName%></title>
<link href="../style/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/prototype.js"></script>
<script src="js/reg.js" type="text/javascript"></script>
</head>
<body>

<%
dim act,gourl,unionid
act=request.QueryString("act")
gourl=request.QueryString("gourl")
if(request.QueryString("gourl")<>"") then
	gourl=request.QueryString("gourl")
elseif(request.ServerVariables("HTTP_REFERER")<>"") then
	gourl=request.ServerVariables("HTTP_REFERER")
else
	gourl="/member/"
end if

if(act<>"" and act="reg") then
	if(isSelfRefer()) then
	else
		call alertstr("禁止外部提交",2)
	end if
	dim rs,UserName,PassWord,RePassWord,IsReg,Email,ForAsk,ForAnswer,CheckCode,UIP,ShopName,HomePage,IndustryId,SalesFor,Province,City,LastId,ContactMan,CatalogId,MemberType
	UserName=replaceBadChar(request.Form("UserName"))
	ContactMan=ShopName
	PassWord=trim(request.Form("PassWord"))
	RePassWord=trim(request.Form("RePassWord"))
	IsReg=""
	Email=GetMax(request.Form("Email"),100)
	ForAsk=GetMax(request.Form("ForAsk"),50)
	ForAnswer=GetMax(request.Form("ForAnswer"),50)
	IndustryId=0
	CatalogId=0
	SalesFor=""
	Province=request.Form("Province")
	'Province=getProvinceTitle(Province)
	City=request.Form("City")
	MemberType=Cint(request.Form("MemberType"))
	CheckCode=request.Form("CheckCode")
	if CheckCode <> CStr(Session("GetCode"))  then 
		call alertstr("错误：\n验证码错误",1)
	end if
	if CheckCode= "" then
		call alertstr("错误：\n验证码错误",1)
	elseif Session("GetCode") = "9999" then
		Session("GetCode")=""
	elseif Session("GetCode") = "" then
		call alertstr("错误：\n验证码错误",1)
	elseif cstr(Session("GetCode"))<>cstr(Trim(CheckCode)) then
		call alertstr("错误：\n您输入的确认码和系统产生的不一致，请重新输入。\n返回后请刷新登录页面后重新输入正确的信息",2)		
	end if
	Session("GetCode")=""
	PassWord=Md5(PassWord,32)
	UIP=GetIp()	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select top 1 id from t_member order by id desc",conn,3,1
	if not rs.eof then
		LastId=rs(0)
	else
		LastId=1
	end if
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member where UserId='"&UserName&"' or Email='"&Email&"'",conn,3,3
	if not rs.eof then
		rs.close
		set rs=nothing
		Response.Write("<script>alert(""此用户或邮箱已存在，请换一个用户名或邮箱试试!"");history.back();</script>")	
	else
		rs.addnew
		rs("UserId")=UserName
		rs("UserPass")=PassWord		
		rs("PassAsk")=ForAsk
		rs("PassAnswer")=ForAnswer
		rs("Email")=Email
		rs("UserName")=ShopName
		rs("Province")=Province
		rs("City")=City		
		rs("Tel")=""
		rs("Mobile")=""
		rs("QQ")=""
		rs("MSN")=""
		rs("HomePage")=""
		rs("Address")=""
		rs("PostCode")=""
		rs("RegDate")=now()
		rs("RegIp")=request.ServerVariables("REMOTE_ADDR")
		rs("LoginNum")=0
		rs("LastLoginIp")=request.ServerVariables("REMOTE_ADDR")
		rs("LastLoginDate")=now()		
		rs("IsLocked")=0
		rs("IsCheck")=1		
		rs("Demons")=Demons
		rs.update
		rs.close
		set rs=nothing
		Response.Cookies("TotCms_Cookie")("UserName")=UserName
		Response.Cookies("TotCms_Cookie")("UserPass")=PassWord
		Response.Cookies("TotCms_Cookie")("LastVisite")=now()
		Response.Cookies("TotCms_Cookie").Expires=Date()+1
		response.Write("成功注册新用户!请登录并完善您的会员信息，我们将尽快审核您提交的资料。")
		response.Redirect(gourl)
	end if
else
%>
<!--#include file="../head.asp"-->
<div class="br"></div>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  	<td>
      <form id="PostForm" name="PostForm" method="post" action="?act=reg&gourl=<%=server.URLEncode(gourl)%>" onsubmit="return check(this)">
      <table width="100%" align="center" cellpadding="0" cellspacing="1" bgcolor="#fff0cf" class="tableborder">
        <tr align="middle">
          <th height="28" colspan="2" class="maintitle">会员注册</th>
        </tr>
        <tr>
          <td height="22" colspan="2" bgcolor="#FFFFFF" class="pformleft"><div align="left">★请仔细填写下面注册信息</div></td>
        </tr>
        <tr>
          <td width="31%" bgcolor="#FFFFFF" class="padleft"><div align="left">用户名：</div></td>
          <td width="69%" bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="UserName" id="UserName" size="20" maxlength="20" onblur="checkUser(this)" />
            (<span class="style3">*</span>)<span id="userMsg"></span></div></td>
        </tr>   
        <tr>
          <td width="31%" bgcolor="#FFFFFF" class="padleft"><div align="left">会员密码(至少4位)：</div></td>
          <td width="69%" bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="PassWord" type="password" id="PassWord" value="" size="20" maxlength="16" />
            (<span class="style3">*</span>)</div></td>
        </tr>
        <tr>
          <td width="31%" bgcolor="#FFFFFF" class="padleft"><div align="left">确认密码(至少4位)：<br />
          </div></td>
          <td bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="RePassWord" type="password" id="RePassWord" value="" size="20" maxlength="16" />
            (<span class="style3">*</span>)</div></td>
        </tr> 
        <tr>
          <td bgcolor="#FFFFFF" class="padleft"><div align="left">姓名：</div></td>
          <td bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="ShopName" id="ShopName" size="20" maxlength="50" />
            (<span class="style3">*</span>)<span id="userMsg"></span></div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF" class="padleft"><div align="left">密码问题：</div></td>
          <td bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="ForAsk" id="ForAsk" size="20" />
            </div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF" class="padleft"><div align="left">问题答案：</div></td>
          <td bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="ForAnswer" id="ForAnswer" size="20" />
          </div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF" class="padleft"><div align="left">Email地址：</div></td>
          <td bgcolor="#FFFFFF" class="pformleft"><div align="left">
            <input name="Email" id="Email" size="20" maxlength="50" onblur="checkEmailExits(this)" />          
            (<span class="style3">*</span>)
            <span id="emailMsg"></span></div></td>
        </tr>
      <tr>
          <td width="31%" bgcolor="#FFFFFF" class="padleft"><div align="left">请输入验证码：</div></td>
    
          <td width="69%" bgcolor="#FFFFFF" class="pformleft">
              <div align="left">
                <input size="5" name="CheckCode" />          
                <% = GetCode() %>
                (<span class="style3">*</span>)</div></td>
        </tr>
        <tr>
          <td height="54" colspan="2" bgcolor="#FFFFFF">
            
              <div align="center" style="text-align:center">
                <input type="hidden" name="MemberType" value="0" />
                <input type="submit" name="Submit" value="注 册" />
                <input type="reset" name="Submit2" value="重 写" />
              </div></td>
        </tr>
      </table>
    </form>
		</td>
	</tr>
</table>
<!--#include file="../root.asp"-->
<%
	end if
%>
</body>
</html>
<%
call connclose()
%>