<!--#include file="conn.asp" -->
<!--#include file="check.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	end if
	useflag=3
%>
<!--#include file="flag.asp"-->
<%
	uname=Trim(Request.QueryString("login"))
	usertype=Trim(Request.QueryString("usertype"))
	dim errorflag,errorstr
	errorflag=0
	errorstr=""
	if uname="" then
		errorflag=1
		errorstr="请输入用户名！"
	else
	  Function isletternumber(strng)
	   isletternumber = false
	   Dim regEx, Match ' Create variables.
	   Set regEx = New RegExp   ' Create a regular expression object (stupid, huh?)
	   regEx.Pattern = "^[A-Za-z0-9]{4,20}$" ' Sets pattern.
	   regEx.IgnoreCase = True   ' Set case insensitivity.
	   Set Match = regEx.Execute(strng)   ' Execute search.
	   if match.count then isletternumber= true
	  End Function
	  if not isletternumber(uname) then
			errorflag=1
			errorstr="用户名要求由4-20个字母或数字组成！"
	  else
			set rs=server.Createobject("ADODB.Recordset")
			
			if usertype="person" then
				sql="select * from person where uname='"&uname&"'"
			elseif usertype="company" then
				sql="select * from company where uname='"&uname&"'"
			elseif usertype="train" then
				sql="select * from train where tname='"&uname&"'"
			else
				sql="select * from school where sname='"&uname&"'"
			end if
			
			rs.open sql,conn,1,1
	
			if not rs.eof then
		 		 errorflag=1
		  		 errorstr="用户名"&uname&"已经存在，请重新选择用户名！"
			end if
			
			rs.close
			set rs=nothing
			conn.close
			set conn=nothing
	  	end if
	end if
	if errorflag=1 then
		response.write("<font color=red>"&errorstr&"</font><br>")
	else
		response.write("用户名"&uname&"还未被注册，您可以使用！")
	end if
%>