
<%
'------------------------------------------------------------
'获取表单数据dim stuid,username,userpwd
stuid=trim(request.Form("stuid"))
username=trim(request.Form("username"))
userpwd=trim(request.Form("userpwd"))
if username="" or userpwd="" then 
response.Write("用户名和密码不能为空")%>
<a href="lx9-3-2a.htm">返回</a>
<%response.end
end if
'--------------------------------------------------
'建立数据库连接
dim cnn
set cnn=server.CreateObject("adodb.connection")
cnnstr="driver={microsoft access driver (*.mdb)};"& _
"dbq="&server.MapPath("jxgl.mdb")
cnn.open cnnstr
'----------------------------------------------------------
'判断用户名是否存在数据库中
strsql1="select * from user where username ='"&username&"' and userpwd='"&userpwd&"'"
set rs=cnn.execute(strsql1)
if rs.eof and rs.bof then
response.Write("用户名或密码错误<a href='lx9-3-2a.htm'>返回</a>")
rs.close
response.End()
end if
'---------------------------------------------------------------
'获取数据 并建立Session变量
session("username")=rs("username")
session("userpwd")=rs("userpwd")
session("id")=rs("id")
cnn.close:set cnn=nothing
response.Redirect "lx9-3-2b.asp"
%>


