- ·上一篇文章:asp获取网页的html代码
- ·下一篇文章:ASP如何得到字符串的每一位字符
ASP用户登录代码
asp+access用户登录代码,其中
huiyuan.mdb数据库名
pUser213 
表名
y_username用户名字段,y_password密码字段.
login.htm页面
<
head>
<
meta 
http-equiv="
Content-Type"
 
content="
text/html
 
charset=gb2312"
>
<
title>
登录<
/title>
<
/head>
<
body>
<
p>
 
<
/p>
<
form 
name="
form1"
 
method="
post"
 
action="
loginnew.asp"
>
 
 
<
table 
width="
200"
 
border="
1"
 
align="
center"
 
cellpadding="
0"
 
cellspacing="
0"
>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
colspan="
2"
>
<
div 
align="
center"
>
登录<
/div>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
width="
57"
>
<
div 
align="
center"
>
用户名<
/div>
<
/td>
 
 
 
 
 
 
<
td 
width="
137"
 
valign="
top"
>
<
input 
name="
username"
 
type="
text"
 
id="
username"
 
size="
25"
>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td>
<
div 
align="
center"
>
密码<
/div>
<
/td>
 
 
 
 
 
 
<
td 
valign="
top"
>
<
input 
name="
password"
 
type="
password"
 
id="
password"
 
size="
25"
>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
colspan="
2"
>
<
div 
align="
center"
>
 
 
 
 
 
 
 
 
 
 
 
<
input 
type="
submit"
 
name="
Submit"
 
value="
提交"
>
 
 
 
 
 
 
 
 
<
/div>
<
/td>
 
 
 
 
<
/tr>
 
 
<
/table>
<
/form>
<
/body>
<
/html>
loginnew.asp网页
<
%
dim 
username,password
 
 
username=request.form("
username"
)
 
password=request.form("
password"
)
 
set 
rs=server.createobject("
adodb.recordset"
) 
 
conn 
= 
"
DBQ="
 
+ 
server.mappath("
huiyuan.mdb"
) 
+ 
"
DefaultDir=
DRIVER=
{Microsoft 
Access 
Driver 
(*.mdb)}
"
 
 
sql="
select 
* 
from 
pUser213 
where 
y_username=&
#39
"
&
#38
username&
#38
"
&
#39
"
 
rs.open 
sql,conn,1,1
 
if 
rs.eof 
then
 
 
response.write 
"
<
script>
alert(&
#39
登录失败&
#39
)
history.back()
<
/script>
"
 
 
response.end
 
 
else
 
 
 
 
if 
rs("
y_password"
)<
>
password 
then
 
 
 
 
 
 
response.write 
"
<
script>
alert(&
#39
登录失败&
#39
)
history.back()
<
/script>
"
 
 
 
 
 
 
response.end 
 
 
 
 
 
 
 
 
 
end 
if 
 
 
 
 
 
 
 
 
 
 
session("
admin"
)=username
response.write"
<
script>
alert(&
#39
登录成功&
#39
)
location.href=&
#39
index.asp&
#39
<
/script>
"
 
 
end 
if
%>
huiyuan.mdb数据库名
pUser213 
表名
y_username用户名字段,y_password密码字段.
login.htm页面
<
head>
<
meta 
http-equiv="
Content-Type"
 
content="
text/html
 
charset=gb2312"
>
<
title>
登录<
/title>
<
/head>
<
body>
<
p>
 
<
/p>
<
form 
name="
form1"
 
method="
post"
 
action="
loginnew.asp"
>
 
 
<
table 
width="
200"
 
border="
1"
 
align="
center"
 
cellpadding="
0"
 
cellspacing="
0"
>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
colspan="
2"
>
<
div 
align="
center"
>
登录<
/div>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
width="
57"
>
<
div 
align="
center"
>
用户名<
/div>
<
/td>
 
 
 
 
 
 
<
td 
width="
137"
 
valign="
top"
>
<
input 
name="
username"
 
type="
text"
 
id="
username"
 
size="
25"
>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td>
<
div 
align="
center"
>
密码<
/div>
<
/td>
 
 
 
 
 
 
<
td 
valign="
top"
>
<
input 
name="
password"
 
type="
password"
 
id="
password"
 
size="
25"
>
<
/td>
 
 
 
 
<
/tr>
 
 
 
 
<
tr>
 
 
 
 
 
 
 
<
td 
colspan="
2"
>
<
div 
align="
center"
>
 
 
 
 
 
 
 
 
 
 
 
<
input 
type="
submit"
 
name="
Submit"
 
value="
提交"
>
 
 
 
 
 
 
 
 
<
/div>
<
/td>
 
 
 
 
<
/tr>
 
 
<
/table>
<
/form>
<
/body>
<
/html>
loginnew.asp网页
<
%
dim 
username,password
 
 
username=request.form("
username"
)
 
password=request.form("
password"
)
 
set 
rs=server.createobject("
adodb.recordset"
) 
 
conn 
= 
"
DBQ="
 
+ 
server.mappath("
huiyuan.mdb"
) 
+ 
"
DefaultDir=
DRIVER=
{Microsoft 
Access 
Driver 
(*.mdb)}
"
 
 
sql="
select 
* 
from 
pUser213 
where 
y_username=&
#39
"
&
#38
username&
#38
"
&
#39
"
 
rs.open 
sql,conn,1,1
 
if 
rs.eof 
then
 
 
response.write 
"
<
script>
alert(&
#39
登录失败&
#39
)
history.back()
<
/script>
"
 
 
response.end
 
 
else
 
 
 
 
if 
rs("
y_password"
)<
>
password 
then
 
 
 
 
 
 
response.write 
"
<
script>
alert(&
#39
登录失败&
#39
)
history.back()
<
/script>
"
 
 
 
 
 
 
response.end 
 
 
 
 
 
 
 
 
 
end 
if 
 
 
 
 
 
 
 
 
 
 
session("
admin"
)=username
response.write"
<
script>
alert(&
#39
登录成功&
#39
)
location.href=&
#39
index.asp&
#39
<
/script>
"
 
 
end 
if
%>
ASP用户登录代码