头疼 差点崩溃 高手看看
一是我写的代码 运行出错 二是师兄写的 正常 我找了好久都不知道我错在哪里 麻烦高手们看看 应该怎么改谢谢啦
一
<%@language="vbscript" codepage="65001"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
</head>
<body>
<%
dim conn,constr
set conn=server.createobject("adodb.connection")
constr="provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("khkl.mdb")
coon.open constr
dim username,password
username=Trim(request.Form("name"))
password=Trim(request.form("password"))
if username<>"" and password<>"" then
dim rs
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from Uyh where U_name='" & username & "'",conn,1,1
if rs.recordcount=1 then
if rs("U_Pass")=password then
response.cookies("admin")="true"
response.Write("<a herf='index.asp'>进入管理页面</a>")
else
response.Write("密码错误")
end if
else
response.Write("用户名不存在")
end if
rs.close
else
response.Write("请输入用户名和密码")
end if
response.Write("<a herf='login.asp'>返回登录</a>")
conn.close
%>
<p> </p>
<hr width="80">
<p align="center">星星制作</p>
</body>
二
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
</head>
<body> <%
'option explicit
dim conn,rs,sql
set conn=server.createobject("adodb.connection")
dim constr
constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("khgl.mdb")
conn.open constr
dim username,password
username=Trim(request.form("name"))
password=Trim(request.form("password"))
If username<>"" and password<>"" Then
Set Rs=Server.CreateObject("ADODB.Recordset")
Rs.Open "Select * From Uyh Where U_Name='" & username & "'",conn,1,1'以用户名查询数据库
If Rs.RecordCount=1 Then'如果有记录,表示用户名存在。限仅有一条记录,防止作弊。(这个关系到网站安全,以后会学到。)
If Rs("U_Pass")=password Then'如果密码正确
Response.Cookies("admin")="true"
Response.Write("<a href='index.asp'>进入管理页</a><br />")
Else
Response.Write("密码错误")
End If
Else
Response.Write("登录用户名有误")
End If
Rs.close
Else
Response.Write("请输入用户名和密码<br />")
End If
Response.Write("<a href='Login.asp'>返回登录页</a>")
conn.close
%>
</body>
</html>