• 沒有找到結果。

會員功能

在文檔中 二手唱片線上交易 (頁 63-98)

第四章 系統製作

4.1 會員功能

本站採用會員制,所以使用者必須註冊成為本站會員才能使 用相關服務。而本子系統的目的則是讓使用者註冊成為本站會

員,因為要註冊成為會員才能擁有購買的權利。

此子系統分為下列幾個功能:

1. 註冊 2. 登入 3. 修改 4. 購買

1. 註冊

(A) INPUT:

在詳細填完個人相關資料後,按下送出的按鈕即可將之資料 送至本系統,如果按的是重新填寫鍵,則所有的相關欄位皆 會被清除掉以便讓使用者再次填寫。如下圖 4.1 所示:

圖 4.1 會員註冊基本資料輸入

(B)PROCESS

首先是先檢查欄位:

function datacheck

if len(mem.id.value)=0 then

msgbox "id不得為空白",64,"錯誤訊息"

if len(mem.pwd1.value)=0 then

focusto(2)

msgbox "確認密碼不得為空白",64,"錯誤訊息"

exit function

end if

if len(mem.name.value)=0 then

if len(mem.addr.value)=0 then

if len(mem.phone.value)=0 then

focusto(8)

msgbox "電話不得為空白",64,"錯誤訊息"

exit function

end if

if len(mem.cellphone.value)=0 then

if len(mem.email.value)=0 then

if instr(mem.email.value,"@")=0 then

mem.submit

end function sub focusto(x)

document.mem.elements(x).focus()

end sub

再來,將之資料送至資料庫處理:

dim rs,adocon

'給予序號且是唯一不為空 function get_sn()

sqlstr="select id_num from mem_data order by id_num"

set rs = adocon.execute(sqlstr) if not rs.eof then

while not rs.eof

get_sn=rs("id_num") rs.movenext

wend

get_sn=get_sn+1

else

get_sn=1 end if end function

function check_pass()

'取得表單的內容

id=request.form=("id") '檢查是否有相同的id

sqlstr="select * from mem_data where id='"& id&"'"

set adocon=server.createobject("adodb.connection") adocon.open"cdsell"

set sal=adocon.execute(sqlstr) if sal.eof then

check_pass=false

else

check_pass=true end if

sal.close adocon.close end function

sub add_reg()

'將資料新增到資料庫

set adocon=server.createobject("adodb.connection") adocon.open"cdsell"

dim id,pwd,name,payway,id_num

dim sex,getway,addr,phone,cellphone,email,inputtime dim sqlstr

id=request.form("id")

id_num=get_sn

if request.form("pwd")<>request.form("pwd1") then

response.write"(<h1><center>密碼錯誤</center></h1>)"

else

pwd=request.form("pwd") end if

name=request.form("name") payway=request.form("payway") sex=request.form("sex")

getway=request.form("getway") addr=request.form("addr") phone=request.form("phone")

cellphone=request.form("cellphone") getway=request.form("getway")

email=request.form("email") inputtime=date()

sqlstr="insert into mem_data values('" & id &"','"

sqlstr=sqlstr & pwd &"','"&id_num&"','"& name &"','"

sqlstr=sqlstr & payway &"','"& sex &"','"&getway&"','"

sqlstr=sqlstr & addr &"','"& phone&"','"

sqlstr=sqlstr &cellphone&"','"&email&"','"&inputtime&"')"

adocon.execute(sqlstr) if err.number<>0 then

response.write"wrong num:"&err.number&"<br>"

response.write"wrong prog:"&err.source&"<br>"

response.write"wrong mesg:"&err.description&"<br>"

else

response.write("<h1><center>") response.write("註冊成功")

response.write("</center></h1>") end if

adocon.close

end sub

sub register()

if check_pass() then show_waring() else

add_reg()

end if end sub

sub show_waring()

response.write("<h1><center>") response.write("該會員已註冊") response.write("</center></h1>") end sub

(C)OUTOUT:

如果使用者在填寫欄位有錯時或是沒有填到欄位,在選取確定鈕之 後,本系統會顯示錯誤訊息。如下圖所示,沒有填到欄位就會顯示錯 誤訊息:

圖4.2 顯示輸入欄位錯誤訊息

另外我們有做一個偵測,即是電子信箱若是沒有包含”@”位元的話 就會出現錯誤訊息,以防使用者填寫錯誤的電子信箱。如下圖:

圖4.3 顯示電子信箱錯誤輸入

當資料確認無誤之後,系統會將其個人會員資料寫進資料庫當中並回 應使用者成功的畫面。如圖4.4

圖4.4 顯示註冊成功訊息

若是帳號已有人申請,則顯示失敗訊息,如圖4.5:

圖4.5 註冊失敗訊息

2. 會員登入

已註冊過的會員可以登入網頁來進入使用者頁面,進而使用會員 資料修改、查詢、購買CD、帳單建立等功能。

(A)INPUT

輸入個人所擁有的帳號密碼來登入,選取確定之後即可送出資料驗 證,選取重新填寫鍵則會清除所輸入的資料重新再填寫。如圖4.6:

圖4.6 會員登入

(B)PROCESS

<script language="VBscript" RunAt="Server">

function check_pass()

set adocon=server.createobject("adodb.connection")

adocon.open"cdsell"

SQLstr="select * from mem_data where id='" & id

SQLstr= SQLstr & "'and pwd='"& pwd & "'"

set sal= adocon.Execute(SQLstr)

if sal.eof then

check_pass=false

else

check_pass=true

<%

response.write("<center><h1><body bgcolor=black text=white>")

if check_pass() then

response.write("歡迎光臨,"&session("id")&"")

response.write("</center></h1>")

response.write("<meta http-equiv='refresh'

content='10;url=http://newandysun.adsldns.org/user.asp'>")

response.write("帳號或密碼錯誤請再試一次")

response.write("</center></h1></body>")

response.write("<meta http-equiv='refresh'

content='10;url=http://newandysun.adsldns.org/login.asp'>")

end if

%>

</html>

(C) OUTPUT

若是帳號和密碼不能同時輸入正確的話就會出現錯誤訊息。如圖4.7:

圖4.7 登入失敗

只有帳號和密碼同時輸入正確才會出現成功的訊息。如圖4.8:

圖4.8 登入成功

在登入成功後,可以按下超連結到會員主頁或是等待10秒網頁會自動 刷新至會員主頁。如圖4.9:

圖4.9 會員主頁 3. 會員修改

(1)確認:

(A)INPUT:

選取會員修改後,首先會再次確認你是否為使用者,所以會再要求輸 入一次帳號密碼。選擇重新填寫鍵則會清除所輸入之值以重新填寫。

如圖4.10:

圖4.10 進入修改程序

當輸入驗證成功之後,便進入了修改畫面。如圖4.11:

圖4.11 修改畫面 (B)PROCESS

首先是驗證修改程序:

function check_pass()

set adocon=server.createobject("adodb.connection")

adocon.open"cdsell"

SQLstr="select * from mem_data where id='" & id

SQLstr= SQLstr & "'and pwd='"& pwd & "'"

set sal= adocon.Execute(SQLstr)

if sal.eof then

check_pass=false

else

check_pass=true

response.write("<center><h1>")

if check_pass() then

response.write("輸入正確,可進入修改")

response.write("請等待一下<br>或是<a

href='http://newandysun.adsldns.org/check.asp'>請按此修改資 料</a>")

response.write("</center></h1>")

response.write("<meta http-equiv='refresh'

content='10;url=http://newandysun.adsldns.org/check.asp'>") else

response.write("帳號或密碼錯誤請再試一次")

response.write("</center></h1>")

end if

接下來是將修改的資料送至系統:

sub update()

set adocon=server.createobject("adodb.connection") adocon.open"cdsell"

dim

pwd1,pwd2,payway1,getway1,phone1,cellphone1,email,oldid,add

response.write("兩密碼不一致!!請重新輸入...")

exit sub

phone1=request.form("phone")

sqlstr="update mem_data set pwd='"

sqlstr=sqlstr & pwd1&"',payway='"&payway1&"',getway='"

sqlstr=sqlstr &

getway1&"',addr='"&addr1&"',phone='"&phone1&"',cellphone='"

sqlstr=sqlstr & cellphone1&"',[e-mail]='"&email&"' where id='"&oldid&"'"

adocon.execute(sqlstr) if err.number<>0 then

response.write"wrong num:"&err.number&"<br>"

response.write"wrong prog:"&err.source&"<br>"

response.write"wrong mesg:"&err.description&"<br>"

else

response.write("<h1><center>") response.write("<p>修改成功</p>")

response.write("<a href='user.asp'>請按此回到會員頁

</a>")

response.write("</center></h1>")

end if

adocon.close

end sub (C)OUTPUT

當在修改時,會有欄位檢查。如圖4.12:

圖4.12 欄位檢查 一切無錯誤,即秀出成功訊息。如圖4.13

圖4.13 修改成功 4. 購物功能

(A)

使用者可以有兩種購物方式,第一種依據編號購買CD。

使用者可以再查詢CD時查看CD編號再以CD編號來購買想要的CD。如圖 4.14

圖4.14 查詢CD

再利用帳單建立功能來建立自己的購物清單。如圖4.15

圖4.15 帳單填寫 (B)PROCESS

首先是帳單欄位檢查

function check()

dim errflag,msg

errflag=true

if len(orderinput.cd_num.value) = 0 then

errflag=false

elseif len(orderinput.total.value) = 0 then

errflag=false

end function

檢查無誤之後就將清單列出:

Dim cn

Dim cd_num,total,id,order_num,ftotal

function get_sn()

sqlstr="select order_num from order_list order by order_num"

get_sn=os("order_num")

total=request.form("total")

cd_num=request.form("cd_num")

set cn = server.createobject ("adodb.connection")

cn.open "cdsell"

id=session("id")

order_num=get_sn

'set rs = cn.execute("select order_num,mem_data.name, phone, addr, cd_num,total from order_list,cd_data,mem_data where cus_num='"&id_num&"' and order_list.cd_num=cd_data.cd_num)

'取出會員資料

set rs =cn.execute("select id_num,name,phone,addr from mem_data where id='"&id&"'")

'rs("total")=rs("total")-total

'取出cd的價錢和庫存的資料

set cs= cn.execute("select price,total from cd_data where cd_num='"&cd_num&"'")

response.write "<td>" & "收件人地址" & "</td>"

response.write "<td>" & order_num & "</td>"

response.write "<td>" & rs("name") & "</td>"

response.write "<td>" & rs("phone") & "</td>"

response.write "<td>" & rs("addr") & "</td>"

response.write "<td>" & cd_num & "</td>"

response.write "<td>" & total*cs("price")& "</td>"

圖4.16 訂單成功成立

反之,則應該是CD已賣完,使用者訊息。如圖4.17

圖4.17 回應使用者已售完訊息 (A)INPUT

另外一種則是利用購物車的方式。如圖4.18

圖4.18 將商品放進購物車 (B)PROCESS

(C)OUTPUT 如下圖 4.19:

圖 4.19 成功放進購物車

購物車是最近比較新式的購物方式,對於使用者而言的確是一大利

多。

4.2 系統管理者

在文檔中 二手唱片線上交易 (頁 63-98)

相關文件