<!--#include file="Inc/EnSysProduct.asp" -->
<!--#include file="inc/Skin_css.asp"-->
<!--#include file="Inc/md5.asp"-->
<!-- #include file="EnHead.asp" -->
<%
dim UserName,Password,PwdConfirm,Question,Answer,Sex,Email,HomePage,CompanyName,Add,Receiver,Postcode,Phone,Fax
UserName=trim(request("UserName"))
Password=trim(request("Password"))
PwdConfirm=trim(request("PwdConfirm"))
Question=trim(request("Question"))
Answer=trim(request("Answer"))
Sex=trim(Request("Sex"))
Email=trim(request("Email"))
HomePage=trim(request("HomePage"))
CompanyName=trim(request("CompanyName"))
Add=trim(request("Add"))
Receiver=trim(request("Receiver"))
Postcode=trim(request("Postcode"))
Phone=trim(request("Phone"))
Mobile=trim(request("Mobile"))
Fax=trim(request("Fax"))
if UserName="" or strLength(UserName)>14 or strLength(UserName)<4 then
	founderr=true
	errmsg=errmsg & "<br><li>Input username (between 4 and 14 characters)</li>"
else
  	if Instr(UserName,"=")>0 or Instr(UserName,"%")>0 or Instr(UserName,chr(32))>0 or Instr(UserName,"?")>0 or Instr(UserName,"&")>0 or Instr(UserName,";")>0 or Instr(UserName,",")>0 or Instr(UserName,"'")>0 or Instr(UserName,",")>0 or Instr(UserName,chr(34))>0 or Instr(UserName,chr(9))>0 or Instr(UserName,"£ ")>0 or Instr(UserName,"$")>0 then
		errmsg=errmsg+"<br><li>Invalid characters was used in the username</li>"
		founderr=true
	end if
end if
if Password="" or strLength(Password)>12 or strLength(Password)<6 then
	founderr=true
	errmsg=errmsg & "<br><li>Input password(between 6 and 12 characters)</li>"
else
	if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or Instr(Password,"£ ")>0 or Instr(Password,"$")>0 then
		errmsg=errmsg+"<br><li>The illegal character in password</li>"
		founderr=true
	end if
end if
if PwdConfirm="" then
	founderr=true
	errmsg=errmsg & "<br><li>Input confirm password(between 6 and 12 characters)</li>"
else
	if Password<>PwdConfirm then
		founderr=true
		errmsg=errmsg & "<br><li>Password and confirm password inconformity</li>"
	end if
end if
if Question="" then
	founderr=true
	errmsg=errmsg & "<br><li>Password hint question can't be blank</li>"
end if
if Answer="" then
	founderr=true
	errmsg=errmsg & "<br><li>Password answer can't be blank</li>"
end if
if Sex="" then
	founderr=true
	errmsg=errmsg & "<br><li>Sex can't be blank</li>"
else
	sex=cint(sex)
	if Sex<>0 and Sex<>1 then
		Sex=1
	end if
end if
if Email="" then
	founderr=true
	errmsg=errmsg & "<br><li>Email can't be blank</li>"
else
	if IsValidEmail(Email)=false then
		errmsg=errmsg & "<br><li>Your Email has the mistake</li>"
   		founderr=true
	end if
end if
if Add="" then
	founderr=true
	errmsg=errmsg & "<br><li>Add can't be blank</li>"
end if
if Postcode="" then
	founderr=true
	errmsg=errmsg & "<br><li>Postcode can't be blank</li>"
end if
if Phone="" then
	founderr=true
	errmsg=errmsg & "<br><li>Tel can't be blank</li>"
end if

if founderr=false then
	dim sqlReg,rsReg
	sqlReg="select * from [User] where UserName='" & Username & "'"
	set rsReg=server.createobject("adodb.recordset")
	rsReg.open sqlReg,conn,1,3
	if not(rsReg.bof and rsReg.eof) then
		founderr=true
		errmsg=errmsg & "<br><li>You register of user have already existed! Please change a customer to try again!</li>"
	else
		rsReg.addnew
		rsReg("UserName")=UserName
		rsReg("Password")=md5(Password)
		rsReg("Question")=Question
		rsReg("Answer")=md5(Answer)
		rsReg("Sex")=Sex
		rsReg("Email")=Email
		rsReg("HomePage")=HomePage
		rsReg("CompanyName")=CompanyName
		rsReg("Add")=Add
		rsReg("Receiver")=Receiver
		rsReg("Postcode")=Postcode
		rsReg("Phone")=Phone
		rsReg("Mobile")=Mobile
		rsReg("Fax")=Fax
		rsReg("RegDate")=Now()
		rsReg.update
		founderr=false
	end if
	rsReg.close
	set rsReg=nothing
end if		
%> 
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="5" valign="top" bgcolor="#FFFFFF"></td>
  </tr>
  <tr> 
    <td height="72" valign="top" bgcolor="#FFFFFF"><table width="843" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="tdbg_left"  width="190" height="179" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="34" class="title_left">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;User 
                  login </td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
              <tr> 
                <td height="10"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td> 
                        <% call ShowUserLogin() %>
                      </td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td height="5"></td>
              </tr>
            </table></td>
          <td width="6"></td>
          <td valign="top"><table Class=border width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td height="206" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td class="title_right" height="32">&nbsp;&nbsp;&nbsp;<img src="Images/smallbook.jpg" width="10" height="10">&nbsp;&nbsp;Member 
                        Center </td>
                    </tr>
                  </table>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="56"> <div align="center">
                          <%
if founderr=false then
	call RegSuccess()
else
	call WriteErrmsg()
end if
%>
                        </div></td>
                    </tr>
                  </table> </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<!-- #include file="Inc/EnFoot.asp" -->
</BODY></HTML>

<%call CloseConn
sub WriteErrMsg()
    response.write "<table align='center' width='300' border='0' cellpadding='2' cellspacing='0' class='border'>"
    response.write "<tr class='title'><td align='center' height='15'>Because the following reason can't register the user!</td></tr>"
    response.write "<tr class='tdbg'><td align='left' height='100'><br>" & errmsg & "<p align='center'>¡¾<a href='javascript:onclick=history.go(-1)'>Return</a>¡¿<br></p></td></tr>"
	response.write "</table>" 
end sub

sub RegSuccess()
    response.write "<table align='center' width='300' border='0' cellpadding='2' cellspacing='0' class='border'>"
    response.write "<tr class='title'><td align='center' height='15'>ucceed and register the user!</td></tr>"
    response.write "<tr class='tdbg'><td align='left' height='100'><br>You register of user name:" & UserName & "<p align='center'>¡¾<a href='javascript:onclick=window.close()'>Close</a>¡¿<br></p></td></tr>"
	response.write "</table>" 
end sub
%>
