呼和浩特宾馆价格:关于ASP中的cookies用法请ASP高手进

来源:百度文库 编辑:高校问答 时间:2024/04/27 18:27:34
我刚刚学习ASP中的response.cookies 但我自己试着写段代码就不能运行了。。不知道为什么
<!-- #include file="conn.asp"-->
<%
if request.cookies("userlogin")=ture then
response.write"欢迎您"
else
response.write"您尚未登陆"
end if
sub login()
If Request.Form("username")<>"" and Request.Form("password")<>"" Then
dim user,pwd
user=request.form("username")
pwd=request.form("password")
sql="select * from user where user='"&user&"'"
set rs=server.Createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write"无此用户"
elseif rs("password")<>pwd then
response.Write"密码错误"
else
response.cookies("userdata")=user&"|"&pwd
Response.Cookies("userlogin")=true
response.redirect("3.asp")
end if
else
Response.Write"请将表单填写完整"
end if
end sub
%>
'这段是2.asp里面的代码用来处理表单并在客户端写入COOKIES

<%
if request.cookies("userlogin")=true
then
response.write"您已经登陆了"
else
response.Write"您尚未登陆!"
end if
%>
'这段是3.asp用来验证是否登陆的代码
对不起我刚刚帖上去的这段代码是后来修改过的又没有完全修改好。。。原本的代码是这个样子的
<!-- #include file="conn.asp"-->
<%
If Request.Form("username")<>"" and Request.Form("password")<>"" Then
dim user,pwd
user=request.form("username")
pwd=request.form("password")
sql="select * from user where user='"&user&"'"
set rs=server.Createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write"无此用户"
elseif rs("password")<>pwd then
response.Write"密码错误"
else
response.cookies("userdata")=user
Response.Cookies("userlogin")=true
response.redirect("3.asp")
end if
else
Response.Write"请将表单填写完整"
end if
%>
’这就是处理表单页面的代码

<%
if request.cookies("userlogin")=true
then
response.write"您已经登陆了"
else
response.Write"您尚未登陆!"
end if
%>
'这段是验证是否登陆的代码

else
response.cookies("userdata")=user&"|"&pwd
Response.Cookies("userlogin")=true
response.redirect("3.asp")
end if
else
Response.Write"请将表单填写完整"
end if
这段有问题。end if 你都结束语句了,怎么还来个else

这是什么代码,写的乱七八糟的,看看你的IF语句乱了,最基本的你都不写好!
肯定有问题啦!