WEB开发网
开发学院WEB开发ASP 网上“店铺”DIY(3) 阅读

网上“店铺”DIY(3)

 2000-08-28 10:51:31 来源:WEB开发网   
核心提示:Buy.asp <HTML><HEAD><title>购货蓝</title><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"></HEAD&g
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=http://www.cncms.com/"file://C:/InetPub/wwwroot/images/title.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=" & chr(34) & "yuaiwu" & chr
(34) ,"DSN=sqlsales;UID=sa;",3,3

if rs.RecordCount <>0 then

Response.Write "此用户已经登记,请选择别的用户名:"

else

dim fld(7)

dim value(7)

fld(0)="ID"

fld(1)="name"

fld(2)="PWD"

fld(3)="Email"

fld(4)="address"

fld(5)="phone"

fld(6)="post"

fld(7)="sfz"

value(0)=Request.Form("txtID")

value(1)=Request.Form("txtname")

value(2)=Request.Form("txtpwd")

value(3)=Request.Form("txtEmail")

value(4)=Request.Form("txtadd")

value(5)=Request.Form("txtphone")

value(6)=Request.Form("txtPost")

value(7)=Request.Form("txtSFZ")

rs.AddNew fld,value

rs.Update

end if

rs.Close

end if

end if

%>

<HTML>

<HEAD>

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

</HEAD>

<BODY bgColor=oldlace>

<p align=center><font size=6 color=midnightblue>会 员 申 请</font></p>

<P>

<form action="registry.asp" method="post">

<TABLE border=1 cellPadding=0 cellSpacing=0 width="100%">

<TR>

<TD bgColor=bisque>用户名</TD>

<TD><INPUT id=txtID name=txtID

style="HEIGHT: 22px; WIDTH: 275px">**</TD></TR>

<TR>

<TD bgColor=bisque>密码</TD>

<TD><INPUT id=passWord1 name=txtPWD

type=password

style="HEIGHT: 22px; WIDTH: 274px">**</TD></TR>

<TR>

<TD bgColor=bisque>确认</TD>

<TD><INPUT id=password2 name=txtPWD1

type=password

style="HEIGHT: 22px; WIDTH: 275px">**</TD></TR>

<TR>

<TD bgColor=bisque>姓名</TD>

<TD><INPUT id=text2 name=txtname

style="HEIGHT: 22px; WIDTH: 274px">**</TD></TR>

<TR>

<TD bgColor=bisque>身份证号码</TD>

<TD><INPUT id=text3 name=txtSFZ

style="HEIGHT: 22px; WIDTH: 274px"></TD></TR>

<TR>

<TD bgColor=bisque>Email</TD>

<TD><INPUT id=text4 name=txtEmail

style="HEIGHT: 22px; WIDTH: 273px"></TD></TR>

<TR>

<TD bgColor=bisque>联系地址:</TD>

<TD><INPUT id=text5 name=txtAdd

style="HEIGHT: 22px; WIDTH: 272px">**</TD></TR>

<TR>

<TD bgColor=bisque>邮政编码:</TD>

<TD><INPUT id=text6

name=txtPost

style="HEIGHT: 22px; WIDTH: 270px">**</TD></TR>

<TR>

<TD bgColor=bisque>联系电话:</TD>

<TD><INPUT id=text5 name=txtPhone

style="HEIGHT: 22px; WIDTH: 270px"></TD></TR>

</TABLE></P>

<P align=center><INPUT id=submit1 name=cmdSubmit type=submit value=确
认><INPUT id=reset1 name=cmdCancel type=reset value=取消></P></FORM>

<P><FONT color=orangered>请注意:</FONT></P>

<UL>

<LI><FONT color=orangered>带有 ** 号的栏目是必须填写的,其他的栏目可以不
填</FONT>

<LI><FONT color=orangered>以上信息应如实填写,以便我们能与您取得及时的联
系</FONT></LI></UL>

<P> </P>

</BODY></HTML>



这个登录界面和大多数网上的登录新用户类似。

小结:
 

  几个程序都做了一个简要地说明,当然,程序做地非常简单,还有很多功能没有
或有待完美,但它却示范了一个简单的范例,在此仅供大家参考。如果大家有兴趣,
可以把上面的程序试一下,祝大家成功!

Tags:网上 店铺 DIY

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接