conn.asp代码:
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={sql server};server=数据库地址;uid=sa;pwd=数据密码;database=数据库表名"
%>
登陆界面index.asp代码:
<%
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!-- #include file="conn.asp" -->
<!-- #include file="inc/md5.asp" -->
<%
sql="select * from config"
set rs_config=conn.execute(sql)
dianming=rs_config("dianming")
if request("action")="" then
%>
<HTML>
<HEAD>
<TITLE><%=dianming%> - 系统登陆</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JavaScript type=text/JavaScript>
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
if (object != "[object]"){
setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
return;
}
clearTimeout(nereidFadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;
direction = 1;
if (object.filters.alpha.opacity > destOp){
direction = -1;
}
delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if (object.filters.alpha.opacity != destOp){
nereidFadeObjects[object.sourceIndex]=object;
nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
}
}
</SCRIPT>
<STYLE>
body {font-family: "宋体";font-size: 12px;text-decoration: none;}
td {font-size: 12px;color: #666666;text-decoration: none;line-height: 18px;font-family: "宋体";}
.S1{
font-family: "宋体";
font-weight: bold;
color: #ffffff;
font-size:16px;
text-decoration: none}
</STYLE>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">
<table width="646" height="425" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<img src="images/login_01.gif" width="646" height="114" alt="仓库管理软件"></td>
</tr>
<tr>
<td>
<img src="images/login_02.gif" width="88" height="311" alt=""></td>
<td width="476" height="311" valign="top" background="images/login_03.gif"><br>
<FORM ACTION="index.asp?action=login" METHOD="post" name="loginform">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="87" height="30" align="right">登录名:</td>
<td valign="middle"><input type="text" name="username" tabindex="1" style="width:160px;"></td>
</tr>
<tr>
<td height="30" align="right">密 码:</td>
<td><INPUT name="pwd" type="password" tabindex="2" style="width:160px;"></td>
</tr>
<tr>
<td height="30" align="right">验证码:</td>
<td height="30"><input type=text name="verifycode" maxLength=6 size="6" tabindex="3" class="textbox">
<font color=red><-请在验证码框输入</font> <IMG style="cursor:hand;" src="inc/verifycode.asp?n=<%=Timer%>" onClick="this.src=this.src;" align="absmiddle"> </td>
</tr>
<tr>
<td height="50" colspan="2" align="center"><input onMouseOver=nereidFade(this,100,10,5) style="FILTER:alpha(opacity=50)" onMouseOut=nereidFade(this,50,10,5) src="images/dl.gif" type="image" tabindex="5" name="enter" border="0" onClick="return checkform()">
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</form><hr size=1 color='#efefef' width='80%' align='left'>Copyright © 2007-2009 Powered By <a href="
http://www.cnshitou.cn" target="_blank">
www.cnshitou.cn</a> 石头网络 Version 2.1<br>
简单进销存管理系统2.1版(仓库管理软件)</td>
<td>
<img src="images/login_04.gif" width="82" height="311" alt=""></td>
</tr>
</table>
</td></tr></table>
<script language=javascript>
<!--
function document.onreadystatechange()
{ var app=navigator.appName;
var verstr=navigator.appVersion;
if(app.indexOf('Netscape') != -1) {
alert('友情提示:\n 您使用的是Netscape浏览器,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。');
} else if(app.indexOf('Microsoft') != -1) {
if (verstr.indexOf('MSIE 3.0')!=-1 || verstr.indexOf('MSIE 4.0') != -1 || verstr.indexOf('MSIE 5.0') != -1 || verstr.indexOf('MSIE 5.1') != -1)
alert('友情提示:\n 您的浏览器版本太低,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。');
}
document.loginform.username.focus();
}
function checkform() {
if(loginform.username.value == '') {
alert('请输入管理账号!');
loginform.username.focus();
return false;
}
if(loginform.pwd.value == '') {
alert('请输入密码!');
loginform.pwd.focus();
return false;
}
if (loginform.verifycode.value == '') {
alert ('请输入验证码!');
loginform.verifycode.focus();
return false;
}
}
//-->
</script>
</html>
<%
else
nowusername=request.form("username")
nowpwd=request.form("pwd")
if Trim(Request.Form("Verifycode"))<>Trim(Session("Verifycode")) then
%>
<script language=javascript>
alert('您输入的后台管理认证码不对,请重新输入!')
window.history.go(-1)
</script>
<%
response.end
end if
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip = Request.ServerVariables("REMOTE_ADDR")
end if
sql="select * from login where (username='"&nowusername&"' and pwd='"&md5(nowpwd)&"') or (bianhao='"&nowusername&"' and pwd='"&md5(nowpwd)&"')"
set rs=conn.execute(sql)
if rs.eof then
conn.execute("insert into rizi(username,class,address) values('"&nowusername&"','登陆失败','"&userip&"')")
%>
<script language=javascript>
alert('登录名称或密码错误!')
window.history.go(-1)
</script>
<%
response.end
end if
conn.execute("insert into rizi(username,class,address) values('"&nowusername&"','登陆成功','"&userip&"')")
set rs_zu=conn.execute("select * from zu_login where id="&rs("id_zu"))
if rs_zu.eof=false then
Response.Cookies("shiwei_zu")=rs_zu("zu")
else
Response.Cookies("shiwei_zu")=""
end if
Response.Cookies("shiwei_username")=rs("username")
Response.Cookies("shiwei_id")=rs("id")
Cookies_Time=1440
Cookies_Time=Dateadd("n",Cookies_Time,Now())
Response.Cookies("shiwei_zu").expires=Cookies_Time
Response.Cookies("shiwei_username").expires=Cookies_Time
Response.Cookies("shiwei_id").expires=Cookies_Time
response.redirect "main.asp"
end if
%>本回答被提问者采纳