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

下載本文檔

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

文檔簡介

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

2、本章書之后的頁面源代碼中都省略這一行,請讀者們注意。第711行:按照圖6-2的模塊化設(shè)計,調(diào)用相應(yīng)文件。所以在本章書之后的頁面源代碼中都省略這兩行,請讀者們注意。WebTop.asp頁面源代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 userinfo.asp頁面源代碼如下:123456789101112親愛的顧客您好,購置商品請先 登錄 注冊 %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頁面源代碼:Guide.asp頁面源代碼:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011

5、1112113114115116117118119120 新開張期間,購物送大禮,你還等什么呢?趕快行動吧 新開張期間,購物即送大禮 新品上市雅芳美容護(hù)膚品 購物須知 你會挑選洗面奶嗎? 專家給你支招:如何保障網(wǎng)上購物 a href=goodsinfo.asp?id=(¥)if rs.eof then exit do%a href=goodsinfo.asp?id=(¥)loopelse%什么商品都還沒有呢! 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 目前沒有商品分類else% a href=goodssort.asp?id=其主要實現(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 對不起,暫無新品! & _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%本店價: %if i mod 2=0 then response.Write else%123456789101112131415161718192021 合作伙伴:隨緣女性用品專賣店 購物首頁 | 關(guān)于我們 | 商城動態(tài) | 業(yè)務(wù)聯(lián)系 | 版權(quán)聲明 | 付款方式

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

11、456789101112131415161718192021222324252627282930313233%if request.Cookies(user_name)= thenresponse.write alert(對不起,您還沒有登陸!); 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ù): 件共計: 元您有預(yù)存款: 元6.2 建立數(shù)據(jù)庫的動態(tài)鏈接由以上網(wǎng)頁文件可以知道,所有與數(shù)據(jù)庫的連接均由conn.asp頁面完成。那么如何連接數(shù)據(jù)庫的呢?我們先來看看conn.asp頁面的源代碼:123456786.3 建立數(shù)據(jù)庫

14、的動態(tài)更新admin_savegoods.asp頁面主要實現(xiàn)代碼:12345678910111213141516%檢測管理員是否已登陸if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或者您還沒有登錄請登錄);window.location.href=admin_login.asp;end if%6.4用戶管理功能設(shè)計savereg.asp頁面主要源代碼: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(請先把必填的信息填寫完整!);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(對不起,該用戶名已經(jīng)存在,請另外選個名字注冊);history.back(-1);else if user_pwduser_repwd then response.Write alert(兩次輸入的密碼不一致,請重新輸入);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(恭喜,注冊成功,!); window.location.href=index.asp;end ifset rs=nothing%checklogin.asp頁面主要實現(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(請先把用戶名或密碼填寫完整!);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(用戶名或密碼錯誤,請重新輸入!);history.back(-1);else response.cookies(user_name)=user_name response.redirect index.aspend if%6.5商品管理功能設(shè)計其主要實現(xiàn)代碼:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556

21、57585960616263646566676869707172%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或您還沒有登陸!);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ù)庫中無數(shù)據(jù)!elsers.pagesize=MaxPerPagers.absolutepage=currentpage% 商品查看與修改 序號商品名稱

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

24、ntPage&/&TotalPages&頁 Response.Write 共有&totalPut&種商品 %其主要實現(xiàn)代碼:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或者您還沒有登錄請登錄);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 沒有此商品else% 商品修改 form name=myform method=post action=admin_saveedit?id= 選擇商品的分類:option value= 商品名稱

26、:input name=goods_name type=text id=goods_name value= size=30 單位:請選擇單位option 只option 個option 張option 對option 件option 副option 套 單價: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ì)說明:保存商品修改頁代碼如下:12345678910111213141

27、5161718%檢測管理員是否已登陸if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或者您還沒有登錄請登錄);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è)計其主要實現(xiàn)代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768

30、6970717273747576777879808182838485868788899091929394959697%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或您還沒有登陸!);window.location.href=login.asp;end if% 訂單狀態(tài):未確認(rèn)已下單已發(fā)貨 已完成 全 部 %開場分頁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ù)庫中無數(shù)據(jù)!elsers.pagesize=MaxPerPagers.absolutepage=currentpage% 訂單管理 序號下單用戶下單時間商品總數(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 首頁 上一頁 Else Response.Write 首頁 Response.Write 上

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

35、52535455565758596061626364656667686970717273747576777879808182838485%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或者您還沒有登錄請登錄);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(錯誤的定單編號);history.back(-1);else% 訂單根本信息可用操作:a href=admin_editorderform.asp?id=修改本訂單a href=admin_delorderform.asp?id=刪除本訂單 訂單編號: 下單時間: 下單用戶: 訂單狀態(tài): 金額: 商品總金額:¥元;快遞費用:¥元;總金額:¥元 快遞單號: 快遞公司: 送貨地址

37、: 聯(lián)系 : : 定單商品信息 商品名稱 單價 商品數(shù)量 金額 ¥元 ¥元 loop% 其主要代碼如下:1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768%if request.Cookies(admin)= thenresponse.Write alert(網(wǎng)絡(luò)超時或者您還沒有登錄請登錄);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(錯誤的定單編號);history.back(-1);else%form id=form1 name=form1 method=post action=admin_saveoederform.asp?id= 修改訂單根本信息 訂單編號: 下單時間: 下單用戶: 訂單狀態(tài): option value=未確認(rèn) 未確認(rèn) option value=已下單 已下單 option value=已發(fā)貨 已發(fā)貨 option value=已完成 已完成 金額: 商品總金額:¥元;快遞費用:¥ input name=textfield3 type=text value=

溫馨提示

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

評論

0/150

提交評論