<!--#include file="head.asp"-->
<!--#include file="md5.asp"-->
<%if session("nyeee_uid")="" then
response.redirect "login.asp"
end if

uid=HtmlEncode(trim(request.form("uid1")))
pwd=trim(request.form("pwd"))
username=HtmlEncode(trim(request.form("username")))
tel=HtmlEncode(trim(request.form("tel")))
email=HtmlEncode(trim(request.form("email")))
qq=HtmlEncode(trim(request.form("qq")))

sql="select * from user where uid='"&session("nyeee_uid")&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if uid<>"" then
if pwd=rs("pwd") then
rs("pwd")=pwd
else
rs("pwd")=md5(pwd)
end if
rs("username")=username
rs("tel")=tel
if email = "" then email = "未填"
rs("email")=email
if qq = "" then qq = "未填"
rs("qq")=qq
rs.update
rs.close  
set rs=nothing
sql="select * from data where uid='"&session("nyeee_uid")&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if not rs.eof then
 For iPage = 1 To rs.recordcount
rs("username")=username
rs("tel")=tel
rs.update
rs.movenext     
if rs.eof then exit for
next
rs.close  
set rs=nothing
conn.close   
set conn=nothing
end if
response.write"<script>alert('修改成功！');location='edituser.asp'</script>"
end if%>

<script language="JavaScript">
function CheckForm()
{

                   //检查年月日是否是合法日期

                   function isdate(intYear,intMonth,intDay){ 

                      if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;     

                      if(intMonth>12||intMonth<1) return false;  

                      if ( intDay<1||intDay>31)return false;  

                      if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30)) return false;  

                      if(intMonth==2){  

                         if(intDay>29) return false;    

                         if((((intYear%100==0)&&(intYear%400!=0))||(intYear%4!=0))&&(intDay>28))return false;  

                        }  

                      return true;  

                   }  

 

                   //检查身份证是否是正确格式

                   function checkCard(cardid) 

                   {

                       var pattern;

                            if (cardid.length==15)

                            {

                                 pattern= /^\d{15}$/;//正则表达式,15位且全是数字

                                 if (pattern.exec(cardid)==null)

                                 {

                                    alert("15位身份证号码必须为数字！")

                                      return false;

                                 }

                                 if (!isdate("19"+cardid.substring(6,8),cardid.substring(8,10),cardid.substring(10,12)))

                                 {

                              alert("身份证号码中所含日期不正确") 

                                 return false;}

                                 

                            }

                            else     if (cardid.length==18)

                            {

                                 pattern= /^\d{17}(\d|x|X)$/;//正则表达式,18位且前17位全是数字，最后一位只能数字,x,X

                                 if (pattern.exec(cardid)==null)

                                 {

                                            alert("18位身份证号码必须为数字！")

                                          return false;

                                 }

                                 if (!isdate(cardid.substring(6,10),cardid.substring(10,12),cardid.substring(12,14)))

                                 {

                                        alert("身份证号码中所含日期不正确") 

                                 return false;

                                 }

                                 var strJiaoYan  =[  "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];

                                 var intQuan =[7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];

                                 var intTemp=0;

                                 for(i = 0; i < cardid.length - 1; i++)

                                 intTemp +=  cardid.substring(i, i + 1)  * intQuan[i];  

                                 intTemp %= 11;

                                 if(cardid.substring(cardid.length - 1,cardid.length).toUpperCase()!=strJiaoYan[intTemp])

                                 {

                                        alert("身份证末位验证码失败！")

                                 return false;

                                 }

                            }

                            else

                            {

                            alert("身份证号长度必须为15或18！")

                            return false;

                            }

                    return true;   

                   }

function isUserID(s) {
    for(i=0;i<s.length;i++) {
        var c=s.charAt(i);
        if(!((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='_'))
        {
            alert("用户名必须使用英文字符,数字 0~9或者下划线 _ ");
            return false;
        }
    }
    return true;
}



	if (document.reg.uid.value.length == 0) {
		alert("请输入您的用户名");
		document.reg.uid.focus();
		return false;
	}
			if(isUserID(document.reg.uid.value)==false)
		{
			document.reg.uid.focus(); 
			return false; 
		} 
	    if(document.reg.uid.value.length < 2){
		alert("用户名不能低于2位");
		document.reg.uid.focus();
		return false;
	}	
	if (document.reg.pwd.value.length == 0) {
		alert("请输入您的密码");
		document.reg.pwd.focus();
		return false;
	}
	if (document.reg.pwd.value.length == 0) {
		alert("请输入您的密码");
		document.reg.pwd.focus();
		return false;
	}

    if(document.reg.pwd.value.length<4){
		alert("密码不能低于4位");
		document.reg.pwd.focus();
		return false;
	}	
	if (document.reg.checkpwd.value.length == 0) {
		alert("请确认您的密码");
		document.reg.checkpwd.focus();
		return false;
	}
	if (document.reg.pwd.value != document.reg.checkpwd.value) {
		alert("您两次输入的密码不一样！请重新输入");
		document.reg.checkpwd.focus();
		return false;
	}


	if (document.reg.UserName.value.length == 0) {
		alert("请输入您的真实姓名");
		document.reg.UserName.focus();
		return false;
	}
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,./'[]{}`1234567890-=\~!@#$%^&*()_+|?><:";
	var errorChar
	errorChar = isCharsInBag(reg.UserName.value,str)
	if (errorChar != "" )
	{
		alert('真实姓名必须是中文');
		reg.UserName.focus();
		return false;
	} 
function isCharsInBag (s, bag)
{ 
var i,c;
for (i = 0; i < s.length; i++)
{ 
c = s.charAt(i);//字符串s中的字符
if (bag.indexOf(c) > -1) 
return c;
}
return "";
}
	
	    if(document.reg.UserName.value.length<2||document.reg.UserName.value.length>4){
		alert("真实姓名不能少于2字多于4字");
		document.reg.UserName.focus();
		return false;
	}	




	if (document.reg.cardid.value.length == 0) {
		alert("请输入您的身份证号");
		document.reg.cardid.focus();
		return false;
	}
		if(checkCard(document.reg.cardid.value)==false)
		{
			document.reg.cardid.focus(); 
			return false; 
		} 
	
	
	
	

		if (document.reg.tel.value.length == 0) {
		alert("请输入您的联系电话");
		document.reg.tel.focus();
		return false;
	}
{
       var tel=document.reg.tel.value;
       for (var i=0;i<tel.length;i++){
              var c=tel.charAt(i);
              if (c<"0" || c>"9") break;
       }
       if (i<8){
              alert("电话号码必须是8位以上的数字！");
			  document.reg.tel.focus();
              return false;
       }

       return true;

}

	if(!isUserID(reg.uid.value))
	{

		alert(report);
		reg.uid.focus();
		return false;
	}

	return true;
}
</script>

 <div align="center">
<form action="" name=reg method=post onSubmit="return CheckForm();">      
                <table width="760" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="CAE2F8">
                  <tr>
                    <td bgcolor="#FFFFFF">
        <TABLE width=760 border=0 align="center" cellPadding=0 cellSpacing=0 bgcolor="CAE2F8">
          <TBODY>
            <TR bgcolor="CAE2F8">
              <TD bgcolor="CAE2F8"><TABLE width=100% border=0 cellPadding=0 cellSpacing=0>
                  <TBODY>
                    <TR bgcolor="EFF7FE">
                      <TD width=23 vAlign=top><IMG 
src="images/arrow_01.gif" alt=arrow width="16" height="16"></TD>
                      <TD><a href="user.asp"><font color="#CC0000">会员中心</font></a> &gt;&gt; 修改资料(<span class="info6">带 <font color="#FF0000">*</font> 号的项目为必填项</span>)</TD>
                        <TD align="right"><font color="#A2CCF2"><b>www.zhaosangw.com</b></font></TD>
                    </TR>
                  </TBODY>
              </TABLE></TD>
            </TR>
          </TBODY>
        </TABLE>
        </tD>
                  </tr>
          <tr>
            <td bgcolor="#FFFFFF"><div align="center"> <br>
                    <TABLE cellSpacing=1 cellPadding=3 width="550" align=center bgColor=CAE2F8 
border=0>
                      <TBODY>
                        <TR bgcolor="#EFF7FE">
                          <TD colSpan=2><P align=left><font color="#CC0000">请正确填写你的信息</font></P></TD>
                        </TR>
                        <TR>
                          <TD width="100" bgcolor="EFF7FE" class=reg_t><div align="right">用户名：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <input name=uid value="<%=rs("uid")%>" size=18 maxlength=20 disabled><input name="uid1" value="<%=rs("uid")%>" size=18 maxlength=20 type="hidden">
                            <font color="#FF0000">*</font> 您的用户名(不能修改)</TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">密码：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT type=password maxLength=16 
size=18 value="<%=rs("pwd")%>" name=pwd>
                            <font color="#FF0000">*</font> 您的登陆口令(4~16个字符)</TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">确认密码：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT name=checkpwd type=password value="<%=rs("pwd")%>" 
size=18 maxLength=16>
                            <font color="#FF0000">*</font> 确认您的密码</TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">姓
                          名：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT name=UserName value="<%=rs("username")%>" size=18 maxLength=10>
                            <font color="#FF0000">*</font> 您的真实姓名</TD>
                        </TR>
                        <TR>
                          <TD align="right" bgcolor="EFF7FE" class=reg_t>身份证号：</TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT name=cardid value="<%=rs("cardid")%>" size=18 maxLength=18 disabled>
                            <font color="#FF0000">*</font> 本站保密，如实填写(不能修改)</TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">联系电话：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT maxLength=20 size=18 value="<%=rs("tel")%>" name=tel>
                            <font color="#FF0000">*</font> 您最常用的电话</TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">Email：</div></TD>
                          <TD bgcolor="#FFFFFF">                          <INPUT name=email value="<%=rs("email")%>" size=18 maxLength=40>                            </TD>
                        </TR>
                        <TR>
                          <TD bgcolor="EFF7FE" class=reg_t><div align="right">QQ：</div></TD>
                          <TD bgcolor="#FFFFFF"><INPUT name=qq value="<%=rs("qq")%>" size=18 maxLength=15 onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">                          </TD>
                        </TR>
                        <TR bgColor=#ffffff>
                          <TD></TD>
                          <TD><input type="submit" value="确定" name="submit">
&nbsp;
    <input type="reset" value="取消" name="reset">
&nbsp;
    <input type="button" value="返回" name="back" onclick="javascript:history.back()"></TD>
                        </TR>
                      </TBODY>
                </TABLE>
<br>
            </td>
          </tr>
        </table>

</FORM>
</div>                                                                                         
<!--#include file="foot.asp"-->                    
<%rs.close                      
set rs=nothing                                                                                                         
conn.close                       
set conn=nothing%>                                                                                                                         
