<%
dim demo_db_cnn_str
dim Glb_ID,Glb_PWD
demo_db_cnn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("User\#User.mdb") & ";Persist Security Info=False;Jet OLEDB:Database Password=12345"
%>

<%
Function NameCheck(data,promptstr)
	dim data_len,temp,is_continue,i
	data_len = Len(data)

	if data_len<=0 then
	  NameCheck = promptstr & "不能为空"
	elseif data_len>25 then
	  NameCheck = promptstr & "超过最大长度"
	else
	  is_continue = 1
	  i = 1
	  while i<=data_len and is_continue=1
	    temp = mid(data,i,1)
	    if (temp="~"  or temp="#" or temp="$" or temp="""" or temp="'" or temp="\" or temp="<" or temp=">") then
		is_continue = 0
	    else
	      i = i+1
	    end if
	  wend
	  if i>data_len then
  		NameCheck = "1"
	  else
		NameCheck = promptstr & "包含非法字符"
	  end if
	end if
End Function
%>



<%
Function PWDCheck(data,promptstr)
	dim data_len,temp,is_continue,i
	data_len = Len(data)

	if data_len>20 then
	  PWDCheck = promptstr & "超过最大长度"
	else
	  is_continue = 1
	  i = 1
	  while i<=data_len and is_continue=1
	    temp = mid(data,i,1)
	    if (temp="'" or temp="""") then
		is_continue = 0
	    else
	      i = i+1
	    end if
	  wend
	  if i>data_len then
  		PWDCheck = "1"
	  else
		PWDCheck = promptstr & "包含非法字符"
	  end if
	end if
End Function
%>



<%
Function GetUserInfo(ID)
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open demo_db_cnn_str
	str = "select * from Table_1 where Table_1.ID='" & ID & "'"
	set rs = cnn.Execute (str, , adCmdText)	

	if rs.eof then
		rs.close
		GetUserInfo = -1
	else
		Glb_PWD = rs("PWD")
		rs.close
		GetUserInfo = 1
	end if

	cnn.close		
End Function
%>



<%
Function AddUser(ID,PWD)
	dim cnn
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open demo_db_cnn_str
	str = "insert into Table_1(ID,PWD) values ('" & ID & "','" & PWD & "')"
	cnn.Execute str,affected, adCmdText

	if affected<>1 then
		AddUser = -1
	else
		AddUser = 1
	end if

	cnn.close		
End Function
%>
 