求助ASP问题

zqc136657523 2010-11-09 11:08:33
有个代码,要求注册时用SESSION存入用户名和密码,然后再登陆,如果正确的话就转入另外一个页面,如果不正确则返回注册页面。下面是代码,知道这个问题很简单, 但是刚学,不会啊。总是错误。
index.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册页面</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<p>用户名:
<input type="text" name="username" id="username" />
</p>
<p>密码:    
<input type="password" name="pwd" id="pwd" />
</p>
<p>                          
<input type="submit" name="submit2" id="submit2" value="提交" />
                       
<input type="reset" name="submit" id="submit" value="重置" />
</p>
</form>
<%
dim ming, word
ming=request.form("username")
word=request.form("pwd")
session("name")=ming
session("password")=word
%>
<p><a href="login.asp">用户你好,请登陆!</a></p>
</body>
</html>

login.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>用户登陆</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="code.asp">
<p>用户名:
<input type="text" name="txtusename" id="txtusename" />
</p>
<p>密码:
   
<input type="password" name="txtpassword" id="txtpassword" />
</p>
<p>         
<input type="submit" name="button" id="button" value="提交" />
             
<input type="reset" name="button2" id="button2" value="重置" />
</p>
</form>
</body>
</html>

code.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>无标题文档</title>
</head>
<%
if txtusername=session("name") and txtpassword=("password") then
response.redirect("index.asp")
else
response.redirect("new.asp")
end if
%>
<body>
</body>
</html>

new.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>新页面</title>
</head>

<body>
用户密码正确,欢迎登陆!
</body>
</html>


...全文
81 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqp123 2010-11-10
  • 打赏
  • 举报
回复
什么思想啊,登录正确直接存session就得了,session("username")=rs("username")
chchmlml 2010-11-09
  • 打赏
  • 举报
回复

index.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body>
<h1>注册页面</h1>
<%
if request("msg")<>"" then
response.Write("<p>"&request("msg")&"</p>")
end if
%>
<form id="form1" name="form1" method="post" action="?action=reg">
<p>用户名:
<input type="text" name="username" id="username" />
</p>
<p>密码:    
<input type="password" name="pwd" id="pwd" />
</p>
<p>                          
<input type="submit" name="submit2" id="submit2" value="提交" />
                       
<input type="reset" name="submit" id="submit" value="重置" />
</p>
</form>
<%
if request("action")="reg" then
dim ming, word
ming=request.form("username")
word=request.form("pwd")
session("name")=ming
session("password")=word

response.Redirect("login.asp?msg=yes")
end if
%>
<p><a href="login.asp">用户你好,请登陆!</a></p>
</body>
</html>

login.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title></title>
</head>

<body>
<h1>用户登陆</h1>
<%
if request("action")="login" then
if request.form("username")=session("name") and request.form("pwd")=session("password") then
response.redirect("new.asp")
else
response.redirect("index.asp?msg=密码或用户名错误")
end if
end if
%>
<%
if request("msg")="yes" then
response.Write("<p>注册后请登录</p>")
end if
%>
<form id="form1" name="form1" method="post" action="?action=login">
<p>用户名:
<input type="text" name="username" id="username" />
</p>
<p>密码:    
<input type="password" name="pwd" id="pwd" />
</p>
<p>                          
<input type="submit" name="submit2" id="submit2" value="提交" />
                       
<input type="reset" name="submit" id="submit" value="重置" />
</p>
</form>
</body>
</html>


new.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>新页面</title>
</head>

<body>
用户密码正确,欢迎登陆!
</body>
</html>

把code.asp去掉了,没用。
很久没写asp了
zqc136657523 2010-11-09
  • 打赏
  • 举报
回复
没办法啊,从基础学起啊。。。。好多不懂,老师也水得很,以为我们都是神童。,
yuji821 2010-11-09
  • 打赏
  • 举报
回复
还用asp啊
全都忘记了,都.net 4.0了

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧