電子商務(wù)網(wǎng)站建設(shè)與完整實(shí)例(李懷恩)04299實(shí)例的源碼和素材_第1頁(yè)
電子商務(wù)網(wǎng)站建設(shè)與完整實(shí)例(李懷恩)04299實(shí)例的源碼和素材_第2頁(yè)
電子商務(wù)網(wǎng)站建設(shè)與完整實(shí)例(李懷恩)04299實(shí)例的源碼和素材_第3頁(yè)
電子商務(wù)網(wǎng)站建設(shè)與完整實(shí)例(李懷恩)04299實(shí)例的源碼和素材_第4頁(yè)
電子商務(wù)網(wǎng)站建設(shè)與完整實(shí)例(李懷恩)04299實(shí)例的源碼和素材_第5頁(yè)
已閱讀5頁(yè),還剩38頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、第六章 電子商務(wù)網(wǎng)站創(chuàng)立實(shí)例學(xué)習(xí)目標(biāo)熟悉ASP與數(shù)據(jù)庫(kù)鏈接與操作熟練代碼的模塊化設(shè)計(jì)及重用能根據(jù)實(shí)際情況建立電子商務(wù)網(wǎng)站用戶(hù)管理功能等的設(shè)計(jì)與實(shí)現(xiàn)熟悉網(wǎng)站的發(fā)布流程6.1建立一個(gè)簡(jiǎn)單的網(wǎng)上商店下面給出首頁(yè)index.asp的源代碼:12345678910111213隨緣網(wǎng)上商店首頁(yè)參數(shù):指定要包含的文件名。 必須包含文件名擴(kuò)展,而且必須將文件名用引號(hào) () 引起來(lái)。 第1行:調(diào)用conn.asp文件,這個(gè)文件主要負(fù)責(zé)連接數(shù)據(jù)庫(kù);第4行:調(diào)用css.css樣式表文件。因本站點(diǎn)就使用一個(gè)樣式表文件,所以不另外建立一個(gè)文件夾存放。因?yàn)樵谝韵碌乃芯W(wǎng)頁(yè)中都需要調(diào)用同樣的css.css樣式表文件,所以在

2、本章書(shū)之后的頁(yè)面源代碼中都省略這一行,請(qǐng)讀者們注意。第711行:按照?qǐng)D6-2的模塊化設(shè)計(jì),調(diào)用相應(yīng)文件。所以在本章書(shū)之后的頁(yè)面源代碼中都省略這兩行,請(qǐng)讀者們注意。WebTop.asp頁(yè)面源代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 userinfo.asp頁(yè)面源代碼如下:123456789101112親愛(ài)的顧客您好,購(gòu)置商品請(qǐng)先 登錄 注冊(cè) %elseset rs=server.createobject(ado

3、db.recordset)rs.open select user_point,user_fund from users where & _user_name=&request.Cookies(user_name)&,conn,1,3response.Cookies(user_fund)=rs(user_fund)response.Cookies(user_point)=rs(user_point)set rs=nothingresponse.write &request.Cookies(user_name)& _ 您好,您目前有&request.Cookies(user_point)&積分,預(yù)

4、存款& _request.Cookies(user_fund)&元 end if%searchinfo.asp頁(yè)面源代碼:Guide.asp頁(yè)面源代碼:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011

5、1112113114115116117118119120 新開(kāi)張期間,購(gòu)物送大禮,你還等什么呢?趕快行動(dòng)吧 新開(kāi)張期間,購(gòu)物即送大禮 新品上市雅芳美容護(hù)膚品 購(gòu)物須知 你會(huì)挑選洗面奶嗎? 專(zhuān)家給你支招:如何保障網(wǎng)上購(gòu)物 a href=goodsinfo.asp?id=(¥)if rs.eof then exit do%a href=goodsinfo.asp?id=(¥)loopelse%什么商品都還沒(méi)有呢! 123456789101112131415161718192021222324%set rs=server.CreateObject(adodb.recordset)rs.open se

6、lect * from goodssort order by sort_order desc,conn,1,1if rs.eof thenresponse.write 目前沒(méi)有商品分類(lèi)else% a href=goodssort.asp?id=其主要實(shí)現(xiàn)代碼如下:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888

7、990919293949596979899100101102103104105106107108109110111112113 %response.write if len(rs(goods_name)12 thenresponse.write left(trim(rs(goods_name),11)&.elseresponse.write trim(rs(goods_name)end ifresponse.write %最熱產(chǎn)品 最新產(chǎn)品 全部產(chǎn)品 %set rs=server.CreateObject(adodb.recordset)rs.open select Top 10 * from

8、 goods order by goods_id desc,conn,1,1if rs.eof thenresponse.write 對(duì)不起,暫無(wú)新品! & _else% %if rs(goods_picture)= then response.write else%a href=goodsinfo.asp?id= img src= width=90 height=90 border=0 align=absmiddle %response.write if len(trim(rs(goods_name)12 thenresponse.write left(trim(rs(goods_name)

9、,10)&.elseresponse.write trim(rs(goods_name)end ifresponse.write % 25 thenresponse.write left(trim(rs(goods_detail),25)&.elseresponse.write trim(rs(goods_detail)end if%本店價(jià): %if i mod 2=0 then response.Write else%123456789101112131415161718192021 合作伙伴:隨緣女性用品專(zhuān)賣(mài)店 購(gòu)物首頁(yè) | 關(guān)于我們 | 商城動(dòng)態(tài) | 業(yè)務(wù)聯(lián)系 | 版權(quán)聲明 | 付款方式

10、 | 留言/建議/投訴 公司地址:廣州市郵政編碼:54321 客服郵箱:客服 :1311111111 工作時(shí)間:724小時(shí)版權(quán)所有 2007-2021 隨緣網(wǎng)上商店 圖6-4 商品詳細(xì)信息頁(yè)面其主要實(shí)現(xiàn)代碼如下:123456789101112131415161718192021222324252627% if rs(goods_picture)= then response.write else %a href= target=_blankimg src= width=200 border=0 alt=點(diǎn)擊在新窗口瀏覽商品大圖 height=200 被瀏覽次已售出次 熱賣(mài)中主要實(shí)現(xiàn)代碼:123

11、456789101112131415161718192021222324252627282930313233%if request.Cookies(user_name)= thenresponse.write alert(對(duì)不起,您還沒(méi)有登陸!); response.write location.href=login.asp;end ifdim goodsid,orderid,amount,num,totalmoneygoodsid=request.QueryString(id)set rs=server.CreateObject(adodb.recordset)rs.open select

12、order_id from orderform where & _user_name=&request.Cookies(user_name)& and order_state=未確認(rèn),conn,1,1 if rs.eof thenconn.execute(insert into orderform(user_name,order_time,order_state) & _values(&request.Cookies(user_name)&,&now&,未確認(rèn))rs.open select order_id from orderform where & _user_name=&request.

13、Cookies(user_name)& and order_state=未確認(rèn),conn,1,1 end iforderid=rs(order_id)conn.execute(insert into orderdetail(order_id,goods_id,goods_amount)values(&orderid&,&goodsid&,1)%訂單里有商品: 件總數(shù): 件共計(jì): 元您有預(yù)存款: 元6.2 建立數(shù)據(jù)庫(kù)的動(dòng)態(tài)鏈接由以上網(wǎng)頁(yè)文件可以知道,所有與數(shù)據(jù)庫(kù)的連接均由conn.asp頁(yè)面完成。那么如何連接數(shù)據(jù)庫(kù)的呢?我們先來(lái)看看conn.asp頁(yè)面的源代碼:123456786.3 建立數(shù)據(jù)庫(kù)

14、的動(dòng)態(tài)更新admin_savegoods.asp頁(yè)面主要實(shí)現(xiàn)代碼:12345678910111213141516%檢測(cè)管理員是否已登陸if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或者您還沒(méi)有登錄請(qǐng)登錄);window.location.href=admin_login.asp;end if%6.4用戶(hù)管理功能設(shè)計(jì)savereg.asp頁(yè)面主要源代碼:12345678910111213141516171819202122232425262728293031323334%dim user_name,user_pwd,user_re

15、pwd,user_realname,user_idcard,user_sex,user_addressdim user_zip,user_telephoneuser_name=request.form(user_name)user_pwd =request.form(user_pwd )user_repwd =request.form(user_repwd )user_realname =request.form(user_realname )user_idcard =request.form(user_idcard )user_sex =request.form(user_sex )user

16、_address =request.form(user_address )user_zip =request.form(user_zip )user_telephone =request.form(user_telephone )if user_name= or user_pwd= or user_realname= or user_address= or _ user_zip= or user_telephone= thenresponse.Write alert(請(qǐng)先把必填的信息填寫(xiě)完整!);history.back(-1);end ifset rs=server.creatobject(

17、)rs.open select user_name from users where user_name=&user_name&if not rs.eof then response.Write alert(對(duì)不起,該用戶(hù)名已經(jīng)存在,請(qǐng)另外選個(gè)名字注冊(cè));history.back(-1);else if user_pwduser_repwd then response.Write alert(兩次輸入的密碼不一致,請(qǐng)重新輸入);history.back(-1); end if (insert into users(user_name,user_password,user_realname, &

18、 _user_idcard,user_sex,user_address) values(&user_name&, & _&user_password &, & user_realname &, & user_idcard &, & _&user_ sex &, &user_ address &) response.cookies(user_name)=user_name response.Write alert(恭喜,注冊(cè)成功,!); window.location.href=index.asp;end ifset rs=nothing%checklogin.asp頁(yè)面主要實(shí)現(xiàn)代碼如下:123

19、4567891011121314151617181920%dim user_name,user_pwduser_name=request.form(user_name)user_pwd =request.form(user_pwd )if user_name= or user_pwd= thenresponse.Write alert(請(qǐng)先把用戶(hù)名或密碼填寫(xiě)完整!);history.back(-1);end ifset rs=server.creatobject()rs.open select user_name from users where user_name=&user_name& &

20、 _ and user_possword=&user_pwd&if rs.eof then response.Write alert(用戶(hù)名或密碼錯(cuò)誤,請(qǐng)重新輸入!);history.back(-1);else response.cookies(user_name)=user_name response.redirect index.aspend if%6.5商品管理功能設(shè)計(jì)其主要實(shí)現(xiàn)代碼:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556

21、57585960616263646566676869707172%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或您還沒(méi)有登陸!);window.location.href=admin_login.asp;end if% const MaxPerPage=10dim totalPut,CurrentPage,TotalPagesif Not isempty(request(page) thencurrentPage=Cint(request(page)elsecurrentPage=1end if set rs=server.C

22、reateObject(adodb.recordset)rs.open select goods_id,goods_name,goods_price,goods_unit,sort_name from & _ goods,goodssort where goodssort.sort_id=goods.sort_id order by & _ goods_id desc,conn,1,1if rs.eof thenResponse.Write 數(shù)據(jù)庫(kù)中無(wú)數(shù)據(jù)!elsers.pagesize=MaxPerPagers.absolutepage=currentpage% 商品查看與修改 序號(hào)商品名稱(chēng)

23、單位單價(jià)分類(lèi)操 作 ¥a href=admin_editgoods.asp?id=修改 a href=admin_delgoods.asp?id=刪除 % If CurrentPage2 Then Response.Write 首頁(yè) 上一頁(yè) Else Response.Write 首頁(yè) Response.Write 上一頁(yè) End IfIf TotalPages-currentpage1 Then Response.Write 下一頁(yè) 尾頁(yè) Else Response.Write 下一頁(yè) Response.Write 尾頁(yè) End If Response.Write 頁(yè)次: & _&Curre

24、ntPage&/&TotalPages&頁(yè) Response.Write 共有&totalPut&種商品 %其主要實(shí)現(xiàn)代碼:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或者您還沒(méi)有登錄請(qǐng)登錄);window.lo

25、cation.href=login.asp;end if%dim goodsidgoodsid=request.QueryString(id)set rs=server.CreateObject(adodb.recordset)rs.open select * from goods where goods_id=&goodsid,conn,1,1if rs.eof thenresponse.Write 沒(méi)有此商品else% 商品修改 form name=myform method=post action=admin_saveedit?id= 選擇商品的分類(lèi):option value= 商品名稱(chēng)

26、:input name=goods_name type=text id=goods_name value= size=30 單位:請(qǐng)選擇單位option 只option 個(gè)option 張option 對(duì)option 件option 副option 套 單價(jià):input name=goods_price type=text id=goods_price value= size=6元 圖片:input name=goods_picture type=text id=goods_picture value= size=30 詳細(xì)說(shuō)明:保存商品修改頁(yè)代碼如下:12345678910111213141

27、5161718%檢測(cè)管理員是否已登陸if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或者您還沒(méi)有登錄請(qǐng)登錄);window.location.href=admin_login.asp;end if保存商品信息dim goodsiddim sort_id,goods_name,goods_unit,goods_price,goods_picture,goods_detailgoodsid=request.QueryString(id)sort_id=request.form(sort_id)goods_name=request.fo

28、rm(goods_name)goods_unit=request.form(goods_unit)goods_price=request.form(goods_price)goods_picture=request.form(goods_picture)goods_detail=request.form(goods_detail)conn.execute(update goods set sort_id=&sort_id&, & _goods_name=&goods_name&,goods_unit= &goods_unit&, & _goods_price=&goods_price&,goo

29、ds_picture= &goods_picture&, & _goods_detail=&goods_detail& where goods_id=&goodsidresponse.Write alert(修改成功); & _window.location.href=admin_goods.asp;%6.6訂單處理功能設(shè)計(jì)其主要實(shí)現(xiàn)代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768

30、6970717273747576777879808182838485868788899091929394959697%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或您還沒(méi)有登陸!);window.location.href=login.asp;end if% 訂單狀態(tài):未確認(rèn)已下單已發(fā)貨 已完成 全 部 %開(kāi)場(chǎng)分頁(yè)Const MaxPerPage=10dim totalPut,CurrentPage,TotalPages,stypestype=request.QueryString(type)if Not isempty(re

31、quest.QueryString (page) thencurrentPage=Cint(request.QueryString (page)elsecurrentPage=1end if select case stypecase unconfirmsql=select * from orderform where order_state=未確認(rèn) order by order_id desccase confirmsql=select * from orderform where order_state=已下單 order by order_id desccase carryingsql=

32、select * from orderform where order_state=已發(fā)貨 order by order_id desccase donesql=select * from orderform where order_state=已完成 order by order_id desccase elsesql=select * from orderform order by order_id descend selectset rs=server.CreateObject(adodb.recordset)rs.open sql,conn,1,3if rs.eof thenRespo

33、nse.Write 數(shù)據(jù)庫(kù)中無(wú)數(shù)據(jù)!elsers.pagesize=MaxPerPagers.absolutepage=currentpage% 訂單管理 序號(hào)下單用戶(hù)下單時(shí)間商品總數(shù)總金額狀 態(tài)操 作 ¥元a href=admin_scanorderform.asp?id=查看詳細(xì) a href=admin_editorderform.asp?id=修改 a href=admin_delorderform.asp?id=刪除 % If CurrentPage2 Then Response.Write 首頁(yè) 上一頁(yè) Else Response.Write 首頁(yè) Response.Write 上

34、一頁(yè) End IfIf TotalPages-currentpage1 Then Response.Write 下一頁(yè) 尾頁(yè) Else Response.Write 下一頁(yè) Response.Write 尾頁(yè) End If Response.Write 頁(yè)次: & _&CurrentPage& & _/&TotalPages&頁(yè) Response.Write 共有&totalPut&份訂單 %主要實(shí)現(xiàn)代碼如下:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051

35、52535455565758596061626364656667686970717273747576777879808182838485%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或者您還沒(méi)有登錄請(qǐng)登錄);window.location.href=login.asp;end if%dim orderidorderid=request.QueryString(id)set rs=server.CreateObject(adodb.recordset)rs.open select * from orderform,users w

36、here order_id=&orderid& and & _ users.user_name=orderform.user_name,conn,1,1if rs.eof thenresponse.Write alert(錯(cuò)誤的定單編號(hào));history.back(-1);else% 訂單根本信息可用操作:a href=admin_editorderform.asp?id=修改本訂單a href=admin_delorderform.asp?id=刪除本訂單 訂單編號(hào): 下單時(shí)間: 下單用戶(hù): 訂單狀態(tài): 金額: 商品總金額:¥元;快遞費(fèi)用:¥元;總金額:¥元 快遞單號(hào): 快遞公司: 送貨地址

37、: 聯(lián)系 : : 定單商品信息 商品名稱(chēng) 單價(jià) 商品數(shù)量 金額 ¥元 ¥元 loop% 其主要代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時(shí)或者您還沒(méi)有登錄請(qǐng)登錄);window.location.href=login.asp;end if%dim orderidor

38、derid=request.QueryString(id)set rs=server.CreateObject(adodb.recordset)rs.open select * from orderform,users where order_id=&orderid& and & _ users.user_name=orderform.user_name,conn,1,1if rs.eof thenresponse.Write alert(錯(cuò)誤的定單編號(hào));history.back(-1);else%form id=form1 name=form1 method=post action=admin_saveoederform.asp?id= 修改訂單根本信息 訂單編號(hào): 下單時(shí)間: 下單用戶(hù): 訂單狀態(tài): option value=未確認(rèn) 未確認(rèn) option value=已下單 已下單 option value=已發(fā)貨 已發(fā)貨 option value=已完成 已完成 金額: 商品總金額:¥元;快遞費(fèi)用:¥ input name=textfield3 type=text value=

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論