<% 
Dim strNoName, strBadUserName, strBadPassword,flag
' 设置错误信息
strNoName = "请选择用户名并输入密码以登录网站"
strBadUserName = "对不起！输入的用户名错误"
strBadPassword = "对不起！输入的密码错误"
' 取得网页表单的值
strUserName = Request.Form("Username")
strUserPassword = Request.Form("Userpassword")
' 是否输入用户名和密码
If strUserName = "" or strUserPassword = "" Then 
   Response.Redirect "UserLogin.asp?ErrorMessage=" & strNoName & "&UserName=" & strUserName
End If
' 检查密码
If strUsername="普通用户" or strUsername="超级用户"  Then
   ' 密码正确，找到用户
  If strUsername="普通用户" and  strUserPassword="001"  Then 
  '进入网站的网页
  Session("UserLevel")=1
  Response.Redirect "main.asp"
  Else If strUsername="超级用户" and  strUserPassword="002" Then
       Session("UserLevel") =2
       Response.Redirect "main.asp"
       Else
       '密码错误
       Response.Redirect "UserLogin.asp?ErrorMessage=" & strBadPassword &_
"&UserName=" & strUserName
       End If  
     End if      
Else
   '用户错误
  Response.Redirect "UserLogin.asp?ErrorMessage=" & strBadPassword &_
"&UserName=" & strUserName
strUserName
End If  %>
