<form name="login" action="loginDo.asp">
<table>
<tr>
<td>用户名</td>
<td><input type="textbox" name="username" value=""></td>
</tr>
<tr>
<td>密码</td>
<td><input type="textbox" name="password" value=""></td>
</tr>
</table>
<input type="submit" value="登陆">
</form>
<%
username = request.querystring("username")
password = request.querystring("password")
if username = "fangxiangliaofa" and password = "123456" then
session("login") = "yes"
response.write "您已经成功登陆"
else
response.write "用户名密码错误,请从新登陆"
end if
%>
<%
if session("login")="" then
Response.Redirect("login.asp")
end if
%>
该博客展示了用ASP实现登录验证的代码。通过表单收集用户名和密码,提交到loginDo.asp处理。若用户名和密码正确,设置session并提示登录成功;否则提示错误。同时,若session为空则重定向到登录页面。
1363

被折叠的 条评论
为什么被折叠?



