
<%
'------------------------------------------------------------
'获取表单数据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-1a.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&"'"
set rs=cnn.execute(strsql1)
if not rs.eof then
response.Write("用户名已经注册<a href='lx9-3-1a.htm'>返回</a>")
rs.close
response.End()
end if
'---------------------------------------------------------------
'插入数据 
dim strsqla,strsqlb
strsqla="insert into user(username,userpwd"
strsqlb=")values("&"'"&username&"'"&",'"&userpwd
if stuid<>"" then 
strsqla=strsqla&",学号"
strsqlb=strsqlb&"','"&stuid
end if
strsql=strsqla&strsqlb&"')"
cnn.execute(strsql)
'if cnn.errors.count=0 then
response.Write("成功输入")
'end if


%>
