本人asp菜鸟,有请高人指点迷津

来源:百度知道 编辑:UC知道 时间:2024/09/28 06:41:26
<%session("number")%>
<%
sub chklogin()
dim numbers
dim pwd
numbers=(request.Form("number"))
pwd=(request.Form("pwd"))
if numbers="" or pwd="" then
response.Write "<script>alert('请输入学号或密码!');history.go(-1);</script>"
response.End()
else
set rs=server.CreateObject("adodb.recordset")
sql="select * from student where number='"&numbers&"'"
rs.open sql,conn,2,3
if numbers=rs("number") and pwd=rs("pwd") then
session("name")=rs("name")
session("number")=rs("number")
response.Redirect("seek.asp")
else
response.Write "<script>alert('学号或密码错误');history.go(-1);</script>"
response.End()
end if
end if
rs.close
set rs=nothing
end sub
%>
<

很 明显
<%
if request.Form("action")="chklogin" then
call chklogin()
end if
%>
request.form("action") 是获取不到变量action的值的 action不是表单对象只是提交动作的时候传过去的参数 不能用request.Form() 用request() 或者 request.QueryString() 才可以
上面那段改成下面形式就可以了
<%
if request.QueryString("action")="chklogin" then
call chklogin()
end if
%>

action="default.asp?action=chklogin
你这个是本页吧
,你提交后,执行的是这个代码
<%
if request.Form("action")="chklogin" then
call chklogin() ‘你在本页就直接写入库了,哪来的跳转
end if
%>

<%session("number")%>
'你用的问号传递 要用request.QueryString()
'万能接收request()别随便用 安全问题大了 该用什么就用什么否则黑心人一个cookies就能叫你网站完蛋
'顺便帮你优化了一下 你自己看看咯

<%
'执行脚本结果提示(提示文字)
sub result_view(result)
response.Write "<script>alert('"&result&"!');history.go(-1)