⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chklogin.asp

📁 在线聊天系统
💻 ASP
字号:
<!--#include file="dbconn.asp"-->
<!--#include file="inc_function.asp"-->

<%

dim username,password  '获取提交过来的用户名和密码
dim html1,html2,html3  '出错提示消息

username=trim(request.form("username"))
password=trim(Request.Form("password"))

'过滤字符:'(单引号)
username=check_login(username) 
password=check_login(password)

application("configload")=""


'定义出错的消息内容
'**************************************
'错误处理:
'如果发现错误:给予提示,并断开数据库连接
sub show_err(msg)
	Response.Flush 
	
'定义出错的消息内容
html1="<html><head><title>出错提示</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head>"
Response.Write html1

%>


<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function window_onunload() {
alert(" \n\n<%=html2%>\n\n");
	
window.open("login.asp","","width=260,height=150,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");

}

//-->
</SCRIPT>

<body  oncontextmenu=self.event.returnValue=false LANGUAGE=javascript onunload="return window_onunload()">
	
	<%
	rs.close
	conn.close
	set rs=nothing
	set conn=nothing
	back=true
	if back=true then 
	%>
	
	
	<script language="javascript">
	<!--
	
	self.close();
	//
		//-->
	</script>
	
	<%
	end if
html3="<p><a href='javascript:history.go(-1)'>点击此处进行修改</a></p>"
html3=html3&"</td></tr></table></body></html>"
Response.Write html3
end sub
%>
<%
'************************************************


if username="" then
    html2="您的用户名不能为空!"
   	call show_err(html2)
   	Response.End 
end if
if password="" then
	html2="您的密码不能为空!"
	call show_err(html2)
		Response.End 
end if

set rs=server.createobject("adodb.recordset")
	sql="select username,password,nickname,online  from userinfor where username='"&username&"' and password='"&password&"'"
on error resume next
rs.open sql,conn,1,3
'Response.Write connstr&"<br>"&sql
'Response.End 
if Err.number <> 0 then
	html2="访问数据库失败:!"&Err.description
	call show_err(html2)
	Response.end
end if

'如果取得的记录数不是1
if rs.RecordCount <> 1 then
	html2="您的用户名或者密码错误!"
	call show_err(html2)
	Response.end
end if

 '出于严谨性,这里再次验证用户名和密码的一致性
 '一般不用再在这里验证
  
 	if trim(rs("password"))=password then    	
 		session("icqlogin")=true
   		session("icqusername")=username
		session("icqnickname")=trim(rs("nickname"))
   	    rs("online")=true
   	    on error resume next
   	    rs.Update 
		rs.close
		conn.close
		set rs=nothing
		set conn=nothing
		if Err.number <> 0 then
			Response.Write Err.description 
		else
		response.redirect "mainpre.asp"
		
		end if
		%>
			
		<%
   	    
	else
		html2="<p>您的用户名或者密码错误!</p>"
		call show_err(html2)
		Response.end

	end if
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -