
2.你说的程序的话。我倒可以给你我最近写图书馆图书管理系统的登录部分的代码。做个参考。涉及到的图片。我就不给了哦。只是给你做给参考。
login.asp页面代码,连接数据库的我就不给了。为了安全
<%@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/htmlcharset=gb2312" />
<link type="text/css" rel="stylesheet" href="css/index.css" />
<script language="javascript" type="text/javascript" src="js/check.js">
</script>
<%
dim sql
sql = "select library_name,create_time,copyright_info from sysest"
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
%>
<title><%=rs("library_name")%></title>
<%
rs.close
conn.close
set rs = nothing
set conn = nothing
%>
</head>
<body>
<div id="content">
<div id="top"><img src="images/top.gif" /></div>
<div id="middle">
<form action="check.asp" name="login" id="login" method="post" onsubmit="return check()">
<ul>
<li>用户账号
<input name="username" type="text" id="username" size="20" maxlength="20" class="input"/>
</li>
<li>用户密码
<input name="pw" type="password" id="pw" size="20" maxlength="20" class="input"/>
</li>
<li>验证码
<input name="code" type="text" id="code" size="4" maxlength="4" style="height:20pxborder:#0099FF solid 1px"/>
<img src="code.asp" alt="刷新验证码" onclick="this.src='code.asp'" style="cursor:pointer" >
<li>
<input type="submit" value="登录" style="padding:0px 15px"/>
<input type="reset" value="重置" style="padding:0px 15px" />
</li>
</ul>
</form>
</div>
<div id="bottom"><img src="images/bottom.gif" /></div>
</div>
</body>
</html>
安全检查的js客服端验证代码如下
//下面的代码部分是是对用户登录的验证的JavaScript代码
function check()
{
var reg = new RegExp("[0-9a-zA-Z]")
//首先是对用户名的判断部分
var username = document.all.username.value
if(username=="")
{
alert("用户名是必填项,不可以为空!")
return false
}
else if(!(reg.test(username)))
{
alert("请不要输入非法字符!")
return false
}
//对密码的判断部分
var pw = document.all.pw.value
if(pw=="")
{
alert("密码是必填项,不可以为空!")
return false
}
else if(!(reg.test(pw)))
{
alert("请不要输入非法字符!")
return false
}
//对验证码的判断部分
var code = document.all.code.value
if(code=="")
{
alert("验证码是必填项,不可以为空!")
return false
}
else if(!(reg.test(code)))
{
alert("请不要输入非法字符!")
return false
}
else
{
return true
}
}
服务器端验证代码
<%@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/htmlcharset=gb2312" />
<title>服务器端验证代码</title>
<style type="text/css">
/*
下面的代码是图书管理系统检测页面的css代码*/
/*
公共部分都css代码*/
*{
margin:0px
padding:0px
}
body{
font-family:Arial, Helvetica, sans-serif
font-size:14px
color:#ff0000
}
ul,li{
list-style:none
}
#content{
text-align:center
margin:100px 50px
}
</style>
</head>
<body>
<%
'首先获得用户输入的用户名、密码、验证码三个东西
dim username,pw,code,bool,bool2
bool = false
bool2 = false
username = request.Form("username")
pw = request.Form("pw")
code = request.Form("code")
'获得输入后,进行用户名、密码、验证码合法性判断,用正则
set re = new RegExp
re.pattern="[a-zA-Z0-9]"
if re.test(username) then
if re.test(pw) then
if re.test(code) then
bool = true
end if
end if
end if
%>
<div id="content">
<ul>
<li>
<%
if not bool then
response.Write("<img src='images/error.gif'/>")
end if
if bool=true and bool2=false then
dim sql
sql = "select admin_name,admin_pw,admin_power from sysadmin where admin_name='"&username&"' and admin_pw='"&pw&"'"
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
'登录成功后记录相关都session
session("power") = rs("admin_power")
session("username") = username
'关闭上面查询完成的rs
rs.close
set rs = nothing
dim getcode
getcode=UCase(Cstr(Session("GetENCode")))
if getcode=code then
bool2 = true
response.Write("<img src='images/loginsuccess.gif'/>")
end if
Session("GetENCode")=""
else
response.Write("<img src='images/error.gif'/>")
end if
end if
%>
</li>
<li>
<%
if not bool then
dim ip,logintime
logintime = now()
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
end if
sql = "insert into errorlog(error_name,error_pw,error_ip,error_time) values('"&username&"','"&pw&"','"&ip&"','"&logintime&"')"
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
response.Write("我们检测到非法字符!已经记录了你的ip!!!")
end if
if not bool2 and bool=true then
response.Write("输入的用户名或密码或验证码错误!!!请后退核实之后再次输入!!!")
end if
if bool2 then
response.Write("登录成功!!!系统在3秒后自动跳转到管理页面!!!")
response.Write("<meta http-equiv='refresh' content='3url=admin/index.asp'>")
response.Write("如果页面无跳转!!!请点击<a href='admin/index.asp'>到管理界面</a>")
end if
conn.close
set conn = nothing
%>
</li>
</ul>
</div>
</body>
</html>
还有css部分差点忘给了
/*
下面的代码是图书管理系统首页的css代码*/
/*
公共部分都css代码*/
*{
margin:0px
padding:0px
}
body{
font-family:Arial, Helvetica, sans-serif
font-size:12px
color:#000000
background:url(../images/bgcolor.gif)
}
/*下面的代码用于对齐用户名和密码输入框*/
.input{
color:#006699
width:100px
height:20px
border:#0099FF solid 1px
}
#content{
text-align:center
margin:100px 50px
}
#middle{
background:url(../images/middle.gif)
width:884px
}
#middle ul{
list-style:none
}
#middle ul,li{
padding:10px 3px
}
<%'作者:凌陈亮www.lingchenliang.com(QQ:57404811)
'函数名:gw_sendmail()
'作用:利用Jmail4.5组件发送EMail
'参数:
'tomail:收件人email邮箱地址。
'subject:邮件标题。
'body:邮件内容。
'如果发送成功,函数将返回True,否则返回False
function gw_sendmail(tomail,subject,body)
dim jmail,smail,smail_pwd,fromname
smail = "57404811@qq.com" '设定发件人邮箱帐号
smail_pwd = "***" '设定发件人邮箱密码
fromname = "**网站" '指定发件人,可为email(如:57404811@qq.com),也可为名称(如:**网站)
set jmail = Server.createobject("jmail.message") '创建JMAIL对象
jmail.silent = true '屏蔽例外错误,true表示邮件发送会忽略错误,不将错误信息返回给 *** 作系统。
jmail.logging = true '使用日志
jmail.charset = "gb2312"
jmail.contentType = "text/html"
jmail.from = smail '设定发件人邮箱
jmail.fromname = fromname '指定发件人
jmail.mailserverusername = smail '设定发件人邮箱帐号
jmail.mailserverpassword = smail_pwd '设定发件人邮箱密码
jmail.addRecipient tomail '设定收件人邮箱帐号
jmail.subject = subject '设定邮件的标题
jmail.body = body '设定邮件的内容
jmail.returnreceipt=true '当对方收到邮件后发回收条
'smtp发信服务器名称如:mail.qq.com、smtp.163.com、smtp.163vip.net、smtp.126.com、smtp.sina.com.cn、smtp.gmail.com、smtp.china.com、smtp.sohu.com
if jmail.send("mail.qq.com")=false then '开始发信并判断发信结果
gw_sendmail=false '发信失败
else
gw_sendmail=true '发信成功
end if
end function
'用户意见/网站留言发送邮件示例
dim name1,mobile,content,body
name1=trim(request.form("name1"))
mobile=trim(request.form("mobile"))
content=trim(request.form("content"))
body=""
body=body & "<p>留言时间:" & now() & "</p>"
body=body & "<p>留言IP:" & request.ServerVariables("REMOTE_ADDR") & "</p>"
body=body & "<p>客户姓名:" & name1 & "</p>"
body=body & "<p>手机号码:" & mobile & "</p>"
body=body & "<p>留言内容:" & content & "</p>"
if gw_sendmail("57404811@qq.com","**网站留言-" & name1,body)=true then '这里填自己的邮箱
call alert("发送成功!","/")
else
call alert("错误:发送失败!","javascript:window.history.back()")
end if
%>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)