<!--#include file="conn.asp"-->
<!--#include file="webconfig.asp"-->
<%dim action
action=request.QueryString("action")%>
<html>
<head>
<title><%=webname%>--新用户注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE type=text/css>
.pad {
	PADDING-LEFT: 150px
}
</style>
<link href="images/css.css" rel="stylesheet" type="text/css">
<style>
td{font-size:9pt;line-height:120%;color:#353535} 
body{font-size:9pt;line-height:120%} 

a:link          { color: #000000; text-decoration: none }
a:visited       { color: #000000; text-decoration: none }
a:active        { color: #000000; text-decoration: none }
a:hover         { color: #336699; text-decoration: none; position: relative; right: 0px; top: 1px }
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onMouseOver="window.status='【<%=webname%>】<%=weburl%> 如果您喜欢本站,别忘了把本站介绍给您的好友哦！：）';return true">
<!--#include file="webtop.asp"-->
<%select case action
case ""%>
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td height="22"> 
      <table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#75A3D0" align="center">
        <tr> 
          <td> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td rowspan="2"> 
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="12v">
                    <tr> 
                      <td class="12v" > 
                        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber3" height="0" width="100%">
                          <tr> 
                            <td> 
                              <table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D0E2FD" width="100%">
                                <tr> 
                                  <td valign="top" bgcolor="#FFFFFF"><br>
                                    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                                      <tr> 
                                        <td height="18"> 
                                          <div align="center"><b><font size=2><%=webname%>注册条约</font></b></div>
                                        </td>
                                      </tr>
                                      <tr> 
                                        <td> 
                                          <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                                            <tr> 
                                              <td> 
                                                <%call tiaoyue()%>
                                              </td>
                                            </tr>
                                          </table>
                                        </td>
                                      </tr>
                                    </table>
                                    <div align="center"> 
                                      <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0">
                                        <tr> 
                                          <form name="form1" method="post" action="reg.asp?action=yes">
                                            <td height="36"> 
                                              <div align="center"> 
                                                <input type="submit" name="Submit4"style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee" value="我 同 意">
                                                &nbsp;&nbsp; 
                                                <input type="button" name="Submit22" value="我 不 同 意" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"onClick="location.href='../'">
                                              </div>
                                            </td>
                                          </form>
                                        </tr>
                                      </table>
                                    </div>
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%case "yes"%>
<table width="759" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td height="22"> 
      <table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#75A3D0" align="center">
        <tr> 
          <td> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td rowspan="2"> 
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="12v">
                    <tr> 
                      <td class="12v" > 
                        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber3" height="0" width="100%">
                          <tr> 
                            <td> <br>
                              <table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D0E2FD" width="100%">
                                <tr> 
                                  <td height="230" bgcolor="#FFFFFF"> 
                                    <div align="center"><font color="#cb6f00">请填写用户信息</font> 
                                    </div>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" >
                                      <form name="userinfo" method="post" action="reg.asp?action=save" >
                                        <tr> 
                                          <td class=pad><font color="#cb6f00">E-Mail&nbsp;&nbsp; 
                                            ：</font> 
                                            <input name="useremail" type="text" id="useremail">
                                            <br>
                                            请填写您有效的邮件地址，以便于我们为您提供有效的服务。</td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color="#cb6f00">用 
                                            户 名：</font> 
                                            <input name="username" type="text" id="username" >
                                            <br>
                                            用于登陆时使用，用户名长度不能小于4且使用英文字母。</td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color="#cb6f00">真实姓名： 
                                            <input name="userzhenshiname" type="text" id="userzhenshiname">
                                            <br>
                                            </font>以便发货确认。 </td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color="#cb6f00">密&nbsp;&nbsp;&nbsp; 
                                            &nbsp;&nbsp;码： 
                                            <input name="userpassword" type="password" id="userpassword">
                                            <br>
                                            </font>长度必须大于6个字符小于50个字符，只能为英语字、数字，例如：snsn2003等。<font color="#cb6f00">&nbsp; 
                                            </font></td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color="#cb6f00">确认密码： 
                                            <input name="userpassword1" type="password" id="userpassword1">
                                            <br>
                                            </font>请将输入的密码再次输入，以免设置密码出错。<font color="#cb6f00">&nbsp; 
                                            </font></td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color=#cb6f00>密码提问： 
                                            <input name="quesion" type="text" id="quesion">
                                            </font>(用于密码遗忘时使用)<font color=#cb6f00>&nbsp; 
                                            </font></td>
                                        </tr>
                                        <tr> 
                                          <td class=pad><font color=#cb6f00>密码答案： 
                                            <input name="answer" type="text" id="answer">
                                            </font>(密码遗忘时将验证此答案) </td>
                                        </tr>
                                        <tr> 
                                          <td class=pad> 
                                            <input onClick="return check();" type="submit" name="Submit3" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"value="提  交" >
                                          </td>
                                        </tr>
                                      </form>
                                    </table>
                                    <table width="10" border="0" align="center" cellpadding="0" cellspacing="0">
                                      <tr> 
                                        <td height="7"></td>
                                      </tr>
                                    </table>
                                  </td>
                                </tr>
                              </table>
                              <br>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%case "save"%>
<!--#include file="md5.asp"-->
<%call saveuser()%>

<%
end select%>
<!--#include file="service.asp"-->
<!--#include file="copyright.asp"-->
</body>
</html>
<%sub tiaoyue()
set rs=server.CreateObject("adodb.recordset")
rs.Open "select regtiaoyue from shop_config",conn,1,1
response.Write trim(rs("regtiaoyue"))
rs.Close
set rs=nothing
end sub
sub saveuser()
if session("regtimes")=1 then
response.Write "<div align=center><font color=red size=60>对不起，您刚注册过用户。<br>请稍后再进行注册！</font></div>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select username,useremail from [user] where username='"&trim(request("username"))&"' or useremail='"&trim(request("useremail"))&"'",conn,1,1
if not rs.eof and not rs.bof then
call usererr()
rs.close
else
rs.close
rs.open "select * from [user]",conn,1,3
rs.addnew
rs("username")=trim(request("username"))
rs("userpassword")=md5(trim(request("userpassword1")))
rs("useremail")=trim(request("useremail"))
rs("quesion")=trim(request("quesion"))
rs("answer")=md5(trim(request("answer")))
rs("userzhenshiname")=trim(request("userzhenshiname"))
rs("adddate")=now()
rs("lastlogin")=now()
rs("logins")=0
rs("youbian")=0
rs("zhifufangshi")=0
rs("songhuofangshi")=0
rs.update
rs.close
set rs=nothing
response.Cookies("bookshop")("username")=trim(request("username"))
response.Cookies("bookshop").expires=date+1
session("regtimes")=1
session.Timeout=1
response.Write "<table width=776 border=0 align=center cellpadding=0 cellspacing=1 bgcolor=#D0E2FD><tr><td height=100 bgcolor=#FFFFFF>"
response.Write "<table width=90% border=0 align=center cellpadding=0 cellspacing=0><tr><td height=80 bgcolor=#EFF5FE class=pad><font color=#cb6f00>用户注册成功</font><br>"
response.Write "恭喜"&request.Cookies("bookshop")("username")&"，您已注册成为["&webname&"]正式用户，请进行下一步操作：<br>"
response.Write "·<a href=myuser.asp?action=shouhuoxx>填写收货人详细资料</a><br>·<a href=index.asp>返回首页</a></td></tr></table></td></tr></table>"
end if
end sub
sub usererr()
response.write "<table width=776 height=80 border=0 align=center cellpadding=0 cellspacing=1 bgcolor=#D0E2FD><tr>"
response.write "<td bgcolor=#FFFFFF><table width=90% border=0 align=center cellpadding=2 cellspacing=0><tr><td class=pad bgcolor=#EFF5FE><font color=#cb6f00>用户注册失败</font></td></tr><tr>"
response.write "<td class=pad bgcolor=#EFF5FE ><font color=#FF0000>·您输入的用户名或Email地址已存在，请返回重新输入！<br>·<a href=javascript:history.go(-1)><font color=red>点击返回上一页</font></a> </font></td></tr></table></td></tr></table>"
end sub
%>


<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
   if(checkspace(document.userinfo.username.value)) {
	document.userinfo.username.focus();
    alert("用户名不能为空，请重新输入！");
	return false;
  }
    if(checkspace(document.userinfo.username.value) || document.userinfo.username.value.length < 4) {
	document.userinfo.username.focus();
    alert("用户名长度不能小于4，请重新输入！");
	return false;
  }
    if(checkspace(document.userinfo.userpassword.value) || document.userinfo.userpassword.value.length < 6) {
	document.userinfo.userpassword.focus();
    alert("密码长度不能小于6，请重新输入！");
	return false;
  }
    if(document.userinfo.userpassword.value != document.userinfo.userpassword1.value) {
	document.userinfo.userpassword.focus();
	document.userinfo.userpassword.value = '';
	document.userinfo.userpassword1.value = '';
    alert("两次输入的密码不同，请重新输入！");
	return false;
  }

 if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.userinfo.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.userinfo.useremail.focus();
   return false;
   }

}


function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>