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