【正文】
weaver_MX中編輯 ASP,可以很方便地應用各種輔助項目,實時測試編輯完成的動態(tài)網(wǎng)頁,設計出功能完善的動態(tài)網(wǎng)頁。 關鍵字 數(shù)據(jù)庫 連接 驗證 Asp 網(wǎng)上書店 ABSTRACT One that is with technology of the puter is growing, the modern society has already reached real information age, how to grasp and use information to seem very important. A lot of panies make use of this market of Inter to reach an agreement, so Inter is no longer simple spread media, it besides information of propagating, and may bee the pivot of changing the social shape. Specify pieces of world not fictitious on it is on Inter, reality, and integrate in actual life gradually. ASP whether one outstanding emerce develop procedure language, because of its editor simple and convenient, function overall characteristic, widely used in development of making, enterprise39。電子商務是能夠在網(wǎng)上完成供、產(chǎn)、銷全部業(yè)務流程的虛擬市場。電子商務的推廣,打破了時空限制,改變了貿(mào)易形態(tài),有助于降低企業(yè)成本和提高企業(yè)競爭力。 “ 網(wǎng)上書店 ” 既可以作為網(wǎng)站的一個子模塊實現(xiàn),也可以作為一個網(wǎng)站單獨運行。用戶驗證信息,收集到的用戶點擊信息,主題層次信息,分析得 出的關聯(lián)規(guī)則表等大量的數(shù)據(jù)都由數(shù)據(jù)庫管理系統(tǒng)管理。沒有強有力的后臺支持,就 不可能實現(xiàn)網(wǎng)上購書 這種電子商務形式。 圖 11 網(wǎng)站結構設計圖 網(wǎng)上 書店交易系統(tǒng)的功能模塊大致分為: ▲ 用戶信息模塊 用戶包括系統(tǒng)用戶和商店客戶。 圖書類目管理: 網(wǎng)上書店交易系統(tǒng)對圖書進行相應的分類,以方便管理。 客戶購書成功需要經(jīng)歷 3個過程:首先客戶將圖書放入購物車(此時為“ 未提交 ” 狀態(tài)),然后結賬即提交給圖書管理員(此時狀態(tài)為 “ 已提交 ” ),最后圖書管理員確認并發(fā)貨(狀態(tài)為 “ 已發(fā)貨 ” ),如圖 12所示。更重要的是, ASP使用的 ActiveX技術基于開放設計環(huán)境,用戶可以自己定義和制作組件加入其中,使自己的動態(tài)網(wǎng)頁幾乎具有無限的擴充能力,這是傳統(tǒng)的 Web編寫工具所遠遠不及的地方。這些信息包括 : 使用 Get或 Post方法傳遞的數(shù)據(jù)、 Server環(huán)境變量、 Cookie信息等。由于 ASP腳本沒有輸出 “ 值 ” 的功能,要完成此功能必須使用Response對象。 ▲ Application對象: Application對象能記錄所有 Web用戶的共有信息,它相當于所有上線用戶的公共變量集合。我們現(xiàn)對 二者進行比較 。 4 使用腳本語言( JavaScript、 VBScript或 PERL)編寫。 8 程序代碼隱藏,客戶端僅能看到 ASP輸出的 HTML文件 。 4 CGI開發(fā)出來的 Web應用程序其程序代碼復用率低。 可見, ASP在數(shù)據(jù)庫訪問、與 HTML的集成、提高服務器的效率等諸多方面都優(yōu)于 CGI,更適應 Web應用程 序開發(fā)的需要,因此本文選擇了 ASP作為個性化頁面生成器的開發(fā)工具。 IIS與 ASP的結合 在過去,客戶端 /服務器結構的設計與 Web的相關技術幾乎處于平行線上,兩者相互獨立并無法作出集成性的設計。 1. 3 技術要點 網(wǎng)頁、圖片制作工具和程序設計語言 ▲ Dreamweaver MX制作網(wǎng)上書店各鏈接層次的網(wǎng)頁。 在設 計實現(xiàn)過程當中,還遇到一些技術問題,特別是與數(shù)據(jù)庫的連接,如何處理它們直接影響到生成頁面的質量和服務器端的效率。分頁顯示的方法有很多種,在這里我們主要使用以下方法:將數(shù)據(jù)庫中所有符合條件的記錄一次性的都讀入 recordset中,存放在內存中,然后通過自定義的變量 MaxPerPage(每頁最多顯示數(shù))、 totalPut(總數(shù))、TotalPages(總頁數(shù))來管理分頁處理。它們分別是 admin管理員表(用于存放后臺管理員的信息)、 category大類表(用于存放圖書分類中大類的信息)、 delivery送貨表(用于存放送貨方式)、 orders訂單表(用于存放訂單信息)、 product圖 書表(用于存放書籍信息)、 review瀏覽 表(用于存放用戶對圖書的瀏覽信息)、 sorts小類表(用于存放圖書分類中小類的信息)、 user用戶表(用于存放用戶信息)。 圖 212 delivery表結構圖 orders表 : username( 寫訂單用戶名 ) 、 actiondate( 日期 ) 、 id(產(chǎn)品編號 )、 productnum( 產(chǎn)品訂購數(shù) 量 ) 、 recepit( 收貨人 ) 、 address( 收貨地址 ) 、 realname( 姓名 ) 、 user(EMAIL)、 usertel( 電話 ) 等。 圖 216 sorts表結構圖 user表 : username( 用戶名 ) 、 user( EMAIL) 、 password( 密碼 ) 、identify( 身份證號 ) 、 adddate( 注冊日期 ) 、 question( 密碼提示 ) 、 answer( 密碼答案 ) 、 postcode( 郵編 ) 、 usertel( 電話 ) 、sex( 性別 ) 、 realname( 姓名 ) 等。定義連接數(shù)據(jù)庫需要的變量 dim conn,connstr,db,rs 39。 Server. MapPath(amp。主要包括下列文件: :客戶登錄及登錄信息處理頁面。 :客戶個人資料修改程序。 ,在客戶端進行信息有效性驗證 ,如果信息填寫不正確 ,則給出相應提示 ,信息填寫正確則進行后臺數(shù)據(jù)處理。如果已經(jīng)注冊過,則返回上一頁面 call MsgBox(對不起,您剛注冊過用戶 !,Back,None) end if 39。trim (request(username))amp。trim(request (user))amp。 39。密碼提示問題 rs(quesion)=trim(request(quesion)) 39。電話 rs(mobile)=trim(request(mobile)) 39。釋放資料 set rs=nothing 39。設定 session對象的超時時間為 1分鐘 =1 39。定義兩個變量,對用戶名和密碼進行處理 dim username,password username=replace(trim(request(username)),39。查詢數(shù) 據(jù)庫 select * from [user] where username=39。 and password=39。 ,conn,1,3 39。您已成功注銷 ! 39。其 ASP代碼如下: !include file=manage/inc/ !include file=inc/ !include file=inc/ % 39。amp。對 post傳遞過來的數(shù)據(jù)進行處理 rs(user)=trim(request(user)) rs(realname)=trim(request(realname)) rs(quesion)=trim(request(quesion)) if trim(request(answer))then 39。amp。 select user,vip,identify,quesion,realname from [user] where username=39。其 ASP代碼如下: !include file=manage/inc/ !include file=inc/ !include file=inc/ % 39。查詢數(shù)據(jù)庫 select password from [user] where username=39。,conn,1,3 39。 :顯示新品圖書。 :查看我的購物車信息,圖書結賬。效果如圖 33 圖 33 圖書詳細信息顯示界面 其關鍵代碼如下 : !include file=manage/inc/ !include file=inc/ % dim id 39。在數(shù)據(jù)庫中查詢圖書 select * from product where id=amp。單擊 [開始搜索 ]出現(xiàn)圖 35的搜索結果。定義變量 dim name dim author dim manufacturer dim enabledate dim expiredate dim smallprice dim largeprice dim code dim OrderField dim Order 39。%amp。and author like 39。 end if if manufacturer then sql=sqlamp。%39。codeamp。smallprice end if if largeprice then largeprice=CDbl(largeprice) sql=sqlamp。expiredateamp。 end if sql=sqlamp。Order 39。分頁顯示 if currentpage1 then urrentpage=1 end if 39。效果如圖 36 圖 36 購物車 icar代碼如下 : !include file=manage/inc/ !include file=inc/ % 39。查看是否已經(jīng)把該圖書放入購物車 select id,username from orders where username=39。 and id=amp。判斷用戶級別 , 根據(jù)用戶級別決定圖書價格 dim iCarRs,iPrice,pNum set iCarRs=() if (cookieName)(username)= then iPrice=0 pNum=0 else 39。39。關閉對象 end if select top 10 , from product inner join orders on = where =39。 and =6,conn,1,1 % 。在購物車里面刪除圖書 case del delete from orders where actionid=amp。usernameamp。 and state=6,conn,1,1 if not and not then call MsgBox(對不起,此商品已存在于您的購物車中,不可以重復添加! ,Close,None) 39。39。 manage/:管理員退出登錄程序。 3. 3. 1 圖書的管理 manage/,首先設計一個表單供管理員輸入圖書資料,單擊 [添加 ]按鈕后,先經(jīng)過有效性驗證,驗證有效后添加到數(shù)據(jù)庫中。圖書日期處理 if request(productdateyear) then productdate=trim(request(productdateyear))amp。初始化 recordset對象 set rs=() select * from product,conn,1,3 39。該頁面還帶有一個搜索用戶的功能,其運行頁面如圖 39 圖 39 客戶管理頁面 其主要代碼如下: !include file=inc/ !include file=inc/ !include file=inc/ % 39。useridamp。管理員賬戶是不能注冊的,但能通過已登陸的有管理權限的管理員添加。取得處理 id號 dim id id=request(Id) end if 39。id) call MsgBox(刪除成功! ,GoUrl,) end If 39。具體步驟如下: ①首先確保安裝了 Web服務器 ,比如 Apache、 Tomcat或 IIS。 這 樣 , 在