为什么logincheck.asp验证登录时总是出错??望高手指点!
大家好,我正在学习网页制作,制作登陆界面.代码都是从网上下载的资料里面的,感觉代码有问题,但是水平很差,不知道该怎么改并完善,我把login.asp,conn.asp,logincheck.asp这3段代码都复制在下边了,还请各位高手指点,谢谢。
login.asp
<!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=gb2312" />
<title>JinYu</title>
<meta name="author" content="jason" />
<style type="text/css">
<!--
.STYLE3 {font-size: 18px; font-weight: bold; }
body {
background-color: #00CCFF;
}
-->
</style>
<script language="javascript">
function check()
{
if(document.form1.username.value=="")
{
alert("请输入内容");
document.form1.username.focus();
return false;
}
if(document.form1.password.value=="")
{
alert("请输入密码");
document.form1.password.focus();
return false;
}
if(document.form1.checkcode.value=="")
{
alert("请输入内容");
docunent.form1.checkcode.focus();
return false;
}
document.form1.submit();
}
</script>
</head>
<body>
<form action="logincheck.asp" method="post" name="form1" target="_parent" id="form1">
<p> </p>
<p> </p>
<table width="390" height="182" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#00CCFF">
<tr>
<td width="190"><div align="center" class="STYLE3">用户名</div></td>
<td width="200"><label>
<div align="center">
<input name="username" type="text" id="username" size="20" />
</div>
</label></td>
</tr>
<tr>
<td><div align="center" class="STYLE3">密码</div></td>
<td><div align="center">
<input name="password" type="password" id="password" size="20" />
</div></td>
</tr>
<tr>
<td><div align="center" class="STYLE3">验证码</div></td>
<td>
<div align="left">
<input name="checkcode" type="text" id="checkcode" size="8" />
<img src="imgchk/validatecode.asp" width="32" height="20" /></div></td>
</tr>
<tr>
<td bgcolor="#00CCFF"><div align="center">
<input name="login" type="button" id="login" onclick="check()" value="登陆" />
</div></td>
<td><div align="center">
<input name="cancel" type="reset" id="cancel" value="重置" />
</div></td>
</tr>
</table>
</form>
</body>
</html>
========================================================================================================
conn.asp
<%
dim conn,DbPath
set conn=Server.CreateObject("ADODB. Connection")
DbPath=Server.MapPath("../classdata/class.mdb")
Conn.open "provider=Microsoft.Jet.OLEDB.4.0;data source="&DbPath
%>
=========================================================================================================
logincheck.asp
<html>
<head>
<title>JinYu</title>
</head>
<!--#include file="../include/conn.asp" -->
<!--#include file="md5.asp" -->
<body>
<%'查询数据库中adminname为用户所输入的用户名的所有信息
set rs=Server.CreatObject("ADODB.Recordset")
sql="Select * Form admin Where adminname='"&user&"'"
rs.open sql,conn,1,3
'检查输入的用户名是否存在,不存在,给出提示信息,并使页面后退
if rs.bof and rs.eof then%>
<script language='javascript'>
alert("错误:此用户名不存在!");
location.href=”javascript:history.go(-1);";
</script>
<%else
'检查输入的密码是否正确,不正确,给出提示信息,并使页面后退
if md5(pwd)<>rs("adminpwd") then%>
<script language="javascript">
alert("错误:您的密码不正确!");
location.href=”javascript:history.go(-1);";
</script>
<%'用户名和密码都正确,将页面跳转到brand.asp
else%>
<script language="javascript">
window.navigate("../web/brand.asp");
</script>
<%end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%
'获取用户提交的验证码
code=trim(request(("checkcode"))
if code<>trim(Session("ProcessControl/login.com_ValidateCode")) then %>
<script language="javascript">
alert("请输入正确的验证码!");
location.href="javascript:history.go(-l);" ;
</script>
<% end if
%>
</body>
</html>
[解决办法]
你打开浏览器internet选项——高级——显示友好http错误前的勾去掉,就会显示具体错误
[解决办法]