为何write出来的两个值不同,可用<>判断老是False?

lisbjing 2003-08-25 10:06:04
<%
dim rndnum,verifycode
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
session("verifycode")=rndnum
'response.write session("verifycode")
'response.end
%>



response.write session("verifycode")
response.write request("inputverifycode")
'response.end


if session("verifycode")<>request("inputverifycode") then
response.write"<SCRIPT language=JavaScript>alert('您输入的验证码不正确。');"
response.write"location.href='login.asp'</SCRIPT>"
founderr=true
end if
session("verifycode")=""
...全文
32 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
61 2003-08-29
  • 打赏
  • 举报
回复
<%
dim rndnum,verifycode
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
session("verifycode")=rndnum

if trim(session("verifycode"))<>trim(request("inputverifycode")) then
alert('您输入的验证码不正确。')
response.write"location.href=login.asp"
founderr=true
end if
session("verifycode")=""
%>
fuzq 2003-08-29
  • 打赏
  • 举报
回复
你把它放错了位置,
因而每次都会更新了,,你看到的是
session("verifycode") 第二次生成的 也就是提交后的
request("inputverifycode") 提交前的
lisbjing 2003-08-29
  • 打赏
  • 举报
回复
我和上面的做法一模一样,可就是不行,不知道怎么回事!
lisbjing 2003-08-25
  • 打赏
  • 举报
回复
我把代码改成这样,也就是判断成立了以后直接输入一个固定字符串都不输出,不知道问题出在哪儿?
if session("verifycode")<>request("inputverifycode") then
response.write "afasfdfas"
response.write "<SCRIPT language=JavaScript> alert('您输入的验证码不正确。');"
response.write"location.href='login.asp'</SCRIPT>"
founderr=true
end if
session("verifycode")=""
anita2li 2003-08-25
  • 打赏
  • 举报
回复
刚才搞错了﹐应该是这样﹕
Response.write 与后面的内容用空格分开试试﹐或者可以改成这样﹕
<% if session("verifycode")<>request("inputverifycode") then %>
<SCRIPT language=JavaScript>
alert('您输入的验证码不正确。');
window.location='login.asp';
</SCRIPT>
<% founderr=true
end if %>
anita2li 2003-08-25
  • 打赏
  • 举报
回复
Response.write 与后面的内容用空格分开试试﹐或者可以改成这样﹕
<% if session("verifycode")<>request("inputverifycode") then %>
<SCRIPT language=JavaScript>
alert('您输入的验证码不正确。');
response.write"location.href='login.asp';
</SCRIPT>
<% founderr=true
end if %>
lisbjing 2003-08-25
  • 打赏
  • 举报
回复
javascrit代码也就是上面的那两行,没错呀,我单独执行过,请高人们帮忙看一下。
pp4u 2003-08-25
  • 打赏
  • 举报
回复
javascript代码不执行不一定是判断的问题,你在生成的页面上查看源文件,看看里面到底有没有这段javascript代码,也许是javascript出错而不执行.
lisbjing 2003-08-25
  • 打赏
  • 举报
回复
inputverifycode是上一页form中的输入框名字
上面的javascript代码为什么一直不执行,气得我不行了。
starwu 2003-08-25
  • 打赏
  • 举报
回复
提交表单页:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim rndnum,verifycode
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
session("verifycode")=rndnum
'response.write session("verifycode")
'response.end
%>
<title>无标题文档</title>
</head>

<body>
<form name="form1" method="post" action="1.asp">
<input type="text" name="inputverifycode">
<input type="submit" name="Submit" value="提交">
<%=session("verifycode")%>
</form>
</body>
</html>

验证代码页:
<%response.write session("verifycode")
response.write request("inputverifycode")
'response.end


if session("verifycode")<>request("inputverifycode") then
response.write"<SCRIPT language=JavaScript>alert('您输入的验证码不正确。');"
response.write"location.href='login.asp'</SCRIPT>"
founderr=true
end if
session("verifycode")=""
%>

测试成功!
starwu 2003-08-25
  • 打赏
  • 举报
回复
楼主记得要把<%
dim rndnum,verifycode
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
session("verifycode")=rndnum
'response.write session("verifycode")
'response.end
%>
这段代码放在表单里提交页面,在判断验证的页面不能再放这段代码了,而且这两段代码不能放在同一个页面,因为提交一次就会刷新这页,然后又会重新成生一个随机变量。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧