欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

后臺管理登錄篇-asp設(shè)計與數(shù)據(jù)庫

 更新時間:2007年02月22日 00:00:00   作者:  

實現(xiàn)功能不難,想要完善,甚至完美,那才叫難。
所以,小弟將功能實現(xiàn)帖出來,和各位初學(xué)者討論討論。至于完善,就看各位自己的想法了

一、建立數(shù)據(jù)庫

在就開始了,我建了一個名為windsn.mdb的數(shù)據(jù)庫,包含4張表
admin表(用于管理員信息):id, name(用戶名), pwd(密碼), ...
concent表(用于存放文檔數(shù)據(jù)):con_id, title, author, part, con, time, num
con_id 自動編號
title 文章標(biāo)題
author 作者或出處
part 文章分類
con 文章內(nèi)容
time 發(fā)表時間(用=now()做初始值)
num 被閱次數(shù)
part表(用于存放文檔分類數(shù)據(jù)):id, part(分類), num
reply表(用于文檔評論):con_id, rep_id, rep_name, rep_con, rep_time
con_id 與表concent中con_id字段相對應(yīng)的字段,數(shù)字類型
rep_id 自動編號
rep_name 參與評論的用戶名
rep_con 評論的內(nèi)容
rep_time 評論時間

連接數(shù)據(jù)庫文件conn.asp

以下是代碼片段:
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\windsn.mdb")
%>


然后,再每一個要連接數(shù)據(jù)庫的頁面前加入一行代碼:<!--#include file="../Conn.asp" -->

二、設(shè)置session

為了防止非法登錄,我們要建立一個session.asp。

以下是代碼片段:
<%
if session("name")="" then 
' 如果用戶名不存在,限制登錄。(還可以再設(shè)置一個字段以增加安全性)
' 如果管理員就只你一個人,那么上面這名可改為if session("name")<>"yourname" 'then這樣安全性會更高,也不用怕有漏洞,但就不靈活了。
response.write"<script>alert('對不起,您還沒有登錄!');
location='http://www.windsn.com/admin.asp'</script>"
response.end
end if
%>


到時候在每個頁面前加入一行代碼:<!--#include file="session.asp" -->


三、管理員登錄

1,登錄界面


登錄界面admin.asp文件,我這里設(shè)置到check.asp驗證

以下是代碼片段:

  <table width="755" border="0" align="center" cellspacing="1" style="font-size:13px; ">
<form name="form1" method="POST" action="check.asp">
    <tr align="center" bgcolor="#eeeeee">
      <td height="35" colspan="2" style="font-size:15px; "><b>管理員入口</b></td>
      </tr>
    <tr bgcolor="#eeeeee">
      <td width="308" align="right"><b>用戶名:</b></td>
      <td width="440"><input name="name" type="text" class="table" id="name" size="25"></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td align="right"><b>密 碼:</b></td>
      <td><input name="pwd" type="password" class="table" id="pwd" size="25"></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td colspan="2">&nbsp;</td>
      </tr>
    <tr align="center" bgcolor="#eeeeee">
      <td colspan="2"><input name="Submit" type="submit" class="table" value=" 登 錄 ">  
        <input name="Submit2" type="button" class="table" value=" 取 消 " 
onClick="javascript:window.location.></td>
      </tr>
</form>
  </table>



驗證登錄頁check.asp<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
以下是代碼片段:
<!--#include file="../Conn.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用戶驗證</title>
</head>
<%
name = request.form("name") '取得用戶名
name = replace(name,"'","") 
pwd = request.form("pwd")    '取得密碼
set rs=server.CreateObject("adodb.recordset") 
sqlstr="select * from admin where name='"& name &"'" &" and pwd='"& pwd & "'"
rs.open sqlstr,conn,1,1 
if rs.eof then
response.redirect "error.asp" '登錄失敗進入error.asp頁
else
session("name")=request.form("name") 
' 設(shè)置session值,以便對頁面進行限制登錄。有了這行代碼,再將上面提到的<!--#include file="session.asp" -->代碼加入到需要限制登錄的頁面中,該頁面就必須登錄成功后才能訪問response.redirect "admins.asp" '登錄成功后進入admins.asp的管理頁,'本頁中就要加入<!--#include file="session.asp" -->代碼
end if
%>
<body>
</body>
</html>

相關(guān)文章

最新評論