<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="login.asp">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><div align="center">用户登陆</div></td>
</tr>
<tr>
<td>用户名:</td>
<td><label>
<input name="userID" type="text" id="userID" size="14" />
</label></td>
</tr>
<tr>
<td>密码:</td>
<td><label>
<input name="password" type="text" id="password" size="14" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label></td>
</tr>
</table>
</form>
<%
'-------------------为防止出错我们定义username和password----------------
dim userID
dim password
'--------用request的form方法来接受login.asp页面传来的值,并付值给我们定义的userID和password
userID=request.form("userID")
password=request.form("password")
'---------判断传来的值是不是空值
if userID="" then
'用response的write的方法输出一个脚本
response.write"<script>alert('用户名不能为空')</script>"
response.end
end if
if password="" then
response.write"<script>alert('密码不能为空')</script>"
response.write ("<meta http-equiv=refresh content='3; url=login.asp'>")'三秒刷新并转向.asp
response.end
end if
'----------判断用户名和密码是不是正确,如果一样的输出"登陆成功"并把session的标志给这个用户,否则就输出"登陆失败"
'set conn=server.createobject("ADODB.Connection")
' conn.provider="microsoft.jet.oledb.4.0"
' conn.open server.MapPath("db1.mdb")
' set rs=server.createobject("ADODB.Recordset")
' sql="select * from yanzheng where name='"& userID & "'" '检查数据库的用户名
' rs.open sql,conn
set conn=server.CreateObject("adodb.connection")
conn.provider="microsoft.jet.oledb.4.0"
conn.open server.MapPath("admin.mdb")
set rs=server.CreateObject("adodb.recordset")
sql="select * from yanzheng where name='"& userID &"'" '检查数据库的用户名
rs.open sql,conn
conn.execute sql
if rs.bof and rs.eof then
response.write ("<script>window.close();</script>")
response.write"<script>alert('无此用户或用户密码错误!')</script>"
else
session("name")=userID'传递变量
session("pwd")=password
response.redirect("123.htm")
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>
怎么样让他验证以后不出来用户名为空.一刷新就是用户名为空.请高手指点!1