日期:2014-05-17  浏览次数:21126 次

如何让Errmsg 的提示运行?真的很简单,
longin.asp
VB code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="CHKPWD.ASP">
  <p>用户名
    <input name="name" type="text" id="name" />
  </p>
  <p>
    <input name="pass" type="text" id="pass" />
  </p>
  <p>
    <input type="text" name="Form_Code" />
    <script language=javascript>document.write("<img src=code.asp align=absmiddle id=Image1 onclick=Image1.src='code.asp?'+Math.random(); alt=看不清楚/>");</script>
  </p>
  <p>
    <input type="submit" name="Submit" value="提交" />
    <input type="reset" name="Submit2" value="重置" />
  </p>
</form>
</body>
</html>



chpwd.asp
VB code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file = "md5.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<% If IsEmpty(Session("GetCode")) Or Session("GetCode") <> UCase(Request.form("Form_Code")) Then
    Response.Write "<script>alert('验证码输入错误!');history.go(-1)</script>"
    Response.End
Else
    Session("GetCode") = Empty    ' 清空Session
End If
'摘取自user;
'if Session("Passed") = False then
     '读取从表单传递过来的身份数据
     UserName = Trim(Request.form("name"))
     UserPwd = Request.form("pass")

     if UserName = "" or UserPwd = "" then
        Errmsg = "请输入用户名和密码"
    '加入判断用户名为空或者是密码为空分别判断;
    
        End If
            set rs = server.createobject("adodb.recordset")
            sql = "Select * from users where UserName = '"&UserName&"'"
            rs.open sql,conn,1,3
            if rs.EOF then
                Errmsg = "用户不存在"
                conn.Close
                Set conn = nothing
            else
                if md5(UserPwd)<>rs.Fields("UserPwd") then
                    Errmsg = "密码不正确"
                    conn.Close
                    Set conn = nothing
                else 
                    Errmsg = ""
                    Session("Passed") = True
                    Session("UserName") = rs.Fields("UserName")
                    Session("Id") = rs.Fields("Id")
                end if
            end if
        ' Else
             Errmsg = "验证码输入错误!"
        ' End If






 %>
</body>
</html>



------解决方案--------------------
If Errmsg<> "" Then
&nb