永发信息网

ASP后台验证码清除

答案:3  悬赏:80  手机版
解决时间 2021-04-21 11:55

<%@language=vbscript codepage=936 %>
<%
option explicit
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
'主要是使随机出现的图片数字随机
%>
<html>
<head>
<title>TEst</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/southidc.css">
<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
-->
</style>
<SCRIPT language=JavaScript>
<!--


if (window.Event)
document.captureEvents(Event.MOUSEUP);

function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;

return false;
}

function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}

}

document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others

function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue = true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onselectstart="return false">
<table width="1003" height="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><table width="998" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="998"><img src="images/01_r1_c1.jpg" width="998" height="135"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r2_c1.jpg" width="998" height="86"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r3_c1.jpg" width="998" height="107"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r4_c1.jpg" width="998" height="87"></td>
</tr>
<tr>
<td width="988" height="243" background="images/01_r5_c1.jpg"><table width="856" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="159" valign="top"><table width="29%" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="Admin_ChkLogin.asp" name=form1 method=post onSubmit="return checkform(form1)" autocomplete="off">
<tr>
<td width="58" height="32"><font color="#FFFFFF">用户名:</font></td>
<td width="190" height="32"><input name="username" value="" type="text" class="input1"></td>
</tr>
<tr>
<td height="32"><font color="#FFFFFF">密 码:</font></td>
<td height="32"><input type="password" name="password" value="" class="input1"></td>
</tr>
<tr>
<td height="32"><font color="#FFFFFF">验证码:</font></td>
<td height="32"><input type="text" name="CheckCode" value="" class="input1"> <img src="inc/checkcode.asp"></td>
</tr>
<tr>
<td height="32">&nbsp;</td>
<td height="32"><input name="image" type="image" src="Image/bt_login.gif" width="70" height="16"></td>
</tr>
</form>
</table></td>
</tr>
<tr>
<td height="36"><div align="center" class="STYLE1">安阳市阳光传媒资讯工作室正版授权   版本编号:SUNSHINE8.NO.0807</div></td>
</tr>
</table></td>
</tr>
</table> <script language=Javascript>
form1.username.focus()
function checkform(form)
{
var flag=true;
if(form("username").value==""){alert("请输入用户名!");form("username").focus();return false};
if(form("password").value==""){alert("请输入密码!");form("password").focus();return false};
if(form("CheckCode").value==""){alert("请输入验证码!");form("CheckCode").focus();return false};
return flag;
}
</script></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

最佳答案

<%@language=vbscript codepage=936 %>
<%
option explicit
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
'主要是使随机出现的图片数字随机
%>
<html>
<head>
<title>TEst</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/southidc.css">
<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
-->
</style>
<SCRIPT language=JavaScript>
<!--




if (window.Event)
document.captureEvents(Event.MOUSEUP);


function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;


return false;
}


function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}


}


document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others


function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue = true;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}


function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onselectstart="return false">
<table width="1003" height="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><table width="998" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="998"><img src="images/01_r1_c1.jpg" width="998" height="135"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r2_c1.jpg" width="998" height="86"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r3_c1.jpg" width="998" height="107"></td>
</tr>
<tr>
<td width="998"><img src="images/01_r4_c1.jpg" width="998" height="87"></td>
</tr>
<tr>
<td width="988" height="243" background="images/01_r5_c1.jpg"><table width="856" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="159" valign="top"><table width="29%" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="Admin_ChkLogin.asp" name=form1 method=post onSubmit="return checkform(form1)" autocomplete="off">
<tr>
<td width="58" height="32"><font color="#FFFFFF">用户名:</font></td>
<td width="190" height="32"><input name="username" value="" type="text" class="input1"></td>
</tr>
<tr>
<td height="32"><font color="#FFFFFF">密 码:</font></td>
<td height="32"><input type="password" name="password" value="" class="input1"></td>
</tr>

<tr>
<td height="32">&nbsp;</td>
<td height="32"><input name="image" type="image" src="Image/bt_login.gif" width="70" height="16"></td>
</tr>
</form>
</table></td>
</tr>
<tr>
<td height="36"><div align="center" class="STYLE1">安阳市阳光传媒资讯工作室正版授权   版本编号:SUNSHINE8.NO.0807</div></td>
</tr>
</table></td>
</tr>
</table> <script language=Javascript>
form1.username.focus()
function checkform(form)
{
var flag=true;
if(form("username").value==""){alert("请输入用户名!");form("username").focus();return false};
if(form("password").value==""){alert("请输入密码!");form("password").focus();return false};

}
</script></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>



问题补充 2009-12-08 09:56

<%@language=VBScript codepage=936 %>


<!--#include file="Conn.asp"-->
<!--#include file="../Inc/Config.asp"-->
<!--#include file="inc/md5.asp"-->


<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if


if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where password='"&password&"' and username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
session.Timeout=SessionTimeout
session("AdminName")=rs("username")
session("AdminPassword")=rs("Password")
session("RndPassword")=RndPassword
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "default.asp"
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()


'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='tdbg'><a href='Login.asp'>&lt;&lt; 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub


Function GetRndPassword(PasswordLen)
Dim Ran,i,strPassword
strPassword=""
For i=1 To PasswordLen
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
strPassword = strPassword & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & Chr(Ran)
End If
Next
GetRndPassword=strPassword
End Function
%>

全部回答

两个地方,改一下就行了:

1、验证码验证成功或失败以后,立即给其Session赋值为空:Session("CheckCode")=""

2、调取验证码图片时,加一个随机数,你那个清除缓存是清除的服务器端缓存,跟客户端没半点关系,具体做法:<img src="CheckCode.asp?rd=<%=ASP随机数%>" />,如果还要点击变换验证码则加: onclick="this.src=CheckCode.asp?' + Math.random()"

if CheckCode="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>验证码不能为空!</li>" end if if session("CheckCode")="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>" end if

和 if CheckCode<>CStr(session("CheckCode")) then FoundErr=True ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>" end if

这两段注释掉,登录的时候就不会执行验证码检查了

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
QQ空间为什么我上传的本地音乐听不了?
南宁市武鸣区地税局自助办税服务在什么地方啊
麻烦您们帮我讲解一下“乐观心态”谢谢…
家里挂风铃有什么讲究
....怎么我家玩CF总是黑屏,系统和游戏都没出
怎么举报好友51里面的相册
上思康尔复精神病医院怎么去啊,有知道地址的
摘抄一段《傅雷家书》中有哲理的片段!
什么东西可以边烧边吃?
南水北调是为了解决水资源空间分布均问的题
DNF要求独自过任务问题
soso问问是什么公司的?
济南科技市场二手psp1000
塘沽津晋高速加油站地址在哪,我要去那里办事
为什么17岁向自己的父亲要抚养费就过期了呢?
推荐资讯
魅丽新娘婚纱婚庆地址在什么地方,想过去办事
记的笔顺的笔顺怎么写,有走字底的字笔顺该怎
不懂建行龙卡管理费他是怎么提问的
按图索骥比喻什么动物,按图索骥的故事
诺基亚N5200能下那些游戏
雪城简介 梁晓声
求一个完美国际ys修改代码,要求好看?
哪些篮球鞋适合打室外,鞋底耐磨,轻便,价格
笑傲江湖的结局是什么
求‘李霜婷’的藏头诗
诺基亚6300能否后台操作?
冲压模具中,凸凹模间的配合间隙与被剪板料的
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?