您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
网上“店铺”DIY(3)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 13:57:44
Buy.asp
<HTML>

<HEAD>

<title>购货蓝</title>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

</HEAD>

<BODY bgColor=lightcyan>

<P align=center><IMG alt="网上书店"

src="file://C:InetPubwwwrootimages itle.jpg"><br>

<BODY bgColor=lightcyan>

<form action=buy.asp method=post>

<script language=vbscript>

function ID(mystr)

pos=0

for i=1 to len(mystr)

if mid(mystr,i,1)="`" then

if pos=0 then

ID=left(mystr,i-1)

exit for

end if

end if

next

end function

 

</script>

<%

function ID(mystr)

pos=0

for i=1 to len(mystr)

if mid(mystr,i,1)="`" then

if pos=0 then

ID=left(mystr,i-1)

exit for

end if

end if

next

end function

function BookName(mystr)

pos=0

for i=1 to len(mystr)

if mid(mystr,i,1)="`" then

if pos=0 then

pos=pos+1

else

BookName=mid(mystr,len(id(name))+2,i-2-len(id(name)))

exit for

end if

end if

next

end function

function Price(mystr)

for i= len(mystr) to 1 step -1

if mid(mystr,i,1)="`" then

if pos=0 then

Price=right(mystr,len(mystr)-i)

exit for

end if

end if

next

end function

select case request.querystring("Name")

case "view"

response.write "浏览"

if session("num")="" then

response.write "目前购货蓝中没有选中的书目!"

else

num=clng(session("num"))

response.write "<table border=1><tr><td>书号</td><td>书名</td><td>单价
</td><td>数量</td><td>小计</td></tr>"

session("sum")=0

for i=0 to num

session("sum")=session("sum")+session("sum_" & cstr(i))

response.write "<tr><td>" & session("ID_" & cstr(i)) & "</td><td>" &
session("BookName_" & cstr(i)) & "</td><td>" & session("price_" & cstr
(i)) & "</td><td><input type=text size=5 name=txtNum" & cstr(i) & "
value=" & session("num_" & cstr(i)) & "><td>" & session("sum_" & cstr
(i)) & "</td></td></tr>"

next

response.write "</table>"

Response.Write "购货总金额:" & session("sum")

end if

case ""

response.write "本页内修改"

num=clng(session("num"))

for i=0 to num

session("num_" & cstr(i))=(request.form("txtNum" & cstr(i)))

session("sum_" & cstr(i))=session("num_" & cstr(i))*session("price_"
& cstr(i))

next

response.write "<table border=1><tr><td>书号</td><td>书名</td><td>单价
</td><td>数量</td><td>小计</td></tr>"

session("sum")=0

for i=0 to num

session("sum")=session("sum")+session("sum_" & cstr(i))

response.write "<tr><td>" & session("ID_" & cstr(i)) & "</td><td>" &
session("BookName_" & cstr(i)) & "</td><td>" & session("price_" & cstr
(i)) & "</td><td><input type=text size=5 name=txtNum" & cstr(i) & "
value=" & session("num_" & cstr(i)) & "><td>" & session("sum_" & cstr
(i)) & "</td></td></tr>"

next

response.write "</table>"

Response.Write "购货总金额:" & session("sum")

case else

response.write "增加"

if session("num")="" then

session("num")=0

else

session("num")=clng(session("num"))+1

end if

num=clng(session("num"))

name=(request.querystring("Name"))

session("ID_" & cstr(num))=id(name)

session("Bookname_" & cstr(num))=bookname(name)

session("price_" & cstr(num))=price(name)

session("sum_" & cstr(num))=price(name)

session("num_" & cstr(num))=1

response.write "<table border=1><tr><td>书号</td><td>书名</td><td>单价
</td><td>数量</td><td>小计</td></tr>"

session("sum")=0

for i=0 to num

session("sum")=session("sum")+session("sum_" & cstr(i))

response.write "<tr><td>" & session("ID_" & cstr(i)) & "</td><td>" &
session("BookName_" & cstr(i)) & "</td><td>" & session("price_" & cstr
(i)) & "</td><td><input type=text size=5 name=txtNum" & cstr(i) & "
value=" & session("num_" & cstr(i)) & "><td>" & session("sum_" & cstr
(i)) & "</td></td></tr>"

next

response.write "</table>"

Response.Write "购货总金额:" & session("sum")

end select

%>

<p><input type=submit value="修改购物蓝"><input type=button value="返
回" onclick=window.location.href="index.asp?flag=<% =session("flag") %
>"></p>

</form>

</BODY>

</HTML>

其运行界面如下:

在下面有总金额的显示,并且购买的数量可以更改。

In.asp
<%@ Language=VBScript %>

<%

if Request.Form("txtUser")="" or Request.Form("txtPWD")="" then

Response.Write "用户名或密码为空,请重新输入,如果您没有注册,请选择注
册!"

else

set rs=server.CreateObject("ADODB.recordset")

rs.Open "select * from info where ID='" & Request.Form("txtUser")
& "'" ,"DSN=sqlsales;UID=sa",3,3

if rs.RecordCount =0 then

Response.Write "此会员号不存在!"

else

if trim(rs.Fields("PWD"))<>trim(Request.Form("txtPWD")) then

Response.Write "密码不正确!"

Response.Write rs.Fields("ID") & "<br>"

Response.Write rs.Fields("PWD") & "<br>"

Response.Write Request.Form("txtPWD")

else

session("UserID")=rs.Fields("ID")

session("UserName")=rs.Fields("Name")

Response.Redirect "index.asp"

'Response.Write rs.Fields("ID") & "<br>"

'Response.Write rs.Fields("PWD") & "<br>"

'Response.Write "欢迎光临!"

end if

end if

rs.Close

end if

%>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

</HEAD>

<BODY>

</BODY>

</HTML>

此段程序用于检测登录的合法性。

Registry.asp
<%@ Language=VBScript %>

<%

if Request.Form("txtID")="" and Request.Form("txtPWD")="" and
Request.Form("txtPWD1")="" and _

Request.Form("txtname")="" and Request.Form("txtSFZ")="" and
Request.Form("txtemail")="" and _

Request.Form("txtAdd")="" and Request.Form("txtPost")="" and
Request.Form("txtPhone")="" then

Response.Write "请认真填写以下内容:"

else

if Request.Form("txtID")="" then

Response.Write "用户名为空,请重新填写!" & "<br>"

elseif Request.Form("txtPWD")="" then

Response.Write "密码为空,请重新填写!" & "<br>"

elseif Request.Form("txtPWD1")="" then

Response.Write "密码校验为空,请重新填写!" & "<br>"

elseif Request.Form("txtName")="" then

Response.Write "姓名为空,请重新填写!" & "<br>"

elseif Request.Form("txtAdd")="" then

Response.Write "联系地址为空,请重新填写!" & "<br>"

elseif Request.Form("txtPost")="" then

Response.Write "邮政编码为空,请重新填写!" & "<br>"

elseif trim(Request.Form("txtPWD"))<>trim(Request.Form("txtPWD1"))
then

Response.Write "密码位与校验位不一致,请重新输入!" & "<br>"

else

set rs=server.CreateObject("ADODB.Recordset")

rs.Open "select * from info where ID='" & trim(Request.Form("txtID"))
& "'" ,"DSN=sqlsales;UID=sa;",3,3

'rs.Open "select * from info where ID="

[1] [2] 下一页


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
  • 上一篇文章:
  • 下一篇文章:
  • 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |