Buy.asp
1<html>
2<head>
3<title>购货蓝</title>
4<meta content="Microsoft Visual Studio 6.0" name="GENERATOR"/>
5</head>
6<body bgcolor="lightcyan">
7<p align="center"><img alt="网上书店" src="file://C:\InetPub\wwwroot\images\title.jpg"/><br/>
8<body bgcolor="lightcyan">
9<form action="buy.asp" method="post">
10<script language="vbscript">
11
12function ID(mystr)
13
14pos=0
15
16for i=1 to len(mystr)
17
18if mid(mystr,i,1)="`" then
19
20if pos=0 then
21
22ID=left(mystr,i-1)
23
24exit for
25
26end if
27
28end if
29
30next
31
32end function
33
34
35
36</script>
37
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 "="" &="" cstr(i)="" cstr(i))="" name='txtNum"' num_"="" size="5" type="text" value=" & session("/><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 "="" &="" cstr(i)="" cstr(i))="" name='txtNum"' num_"="" size="5" type="text" value=" & session("/><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 "="" &="" cstr(i)="" cstr(i))="" name='txtNum"' num_"="" size="5" type="text" value=" & session("/><td>" & session("sum_" & cstr
(i)) & "</td></td></tr>"
next
response.write "</table>"
Response.Write "购货总金额:" & session("sum")
end select
1
2<p><input type="submit" value="修改购物蓝"/><input %="" =session("flag")="" onclick='window.location.href="index.asp?flag=```' type="button" value="返
3回"/>"&gt;</p>
4</form>
5</body>
6</p></body></html>
其运行界面如下:
在下面有总金额的显示,并且购买的数量可以更改。
In.asp
<%@ Language=VBScript
1
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") & "
1<br/>
"
Response.Write rs.Fields("PWD") & "
1<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") & "
1<br/>
"
'Response.Write rs.Fields("PWD") & "
1<br/>
"
'Response.Write "欢迎光临!"
end if
end if
rs.Close
end if
Registry.asp
1@ Language=VBScript
1
2
3if Request.Form("txtID")="" and Request.Form("txtPWD")="" and
4Request.Form("txtPWD1")="" and _
5
6Request.Form("txtname")="" and Request.Form("txtSFZ")="" and
7Request.Form("txtemail")="" and _
8
9Request.Form("txtAdd")="" and Request.Form("txtPost")="" and
10Request.Form("txtPhone")="" then
11
12Response.Write "请认真填写以下内容:"
13
14else
15
16if Request.Form("txtID")="" then
17
18Response.Write "用户名为空,请重新填写!" & "
<br/>
1"
2
3elseif Request.Form("txtPWD")="" then
4
5Response.Write "密码为空,请重新填写!" & "
<br/>
1"
2
3elseif Request.Form("txtPWD1")="" then
4
5Response.Write "密码校验为空,请重新填写!" & "
<br/>
1"
2
3elseif Request.Form("txtName")="" then
4
5Response.Write "姓名为空,请重新填写!" & "
<br/>
1"
2
3elseif Request.Form("txtAdd")="" then
4
5Response.Write "联系地址为空,请重新填写!" & "
<br/>
1"
2
3elseif Request.Form("txtPost")="" then
4
5Response.Write "邮政编码为空,请重新填写!" & "
<br/>
1"
2
3elseif trim(Request.Form("txtPWD"))<>trim(Request.Form("txtPWD1"))
4then
5
6Response.Write "密码位与校验位不一致,请重新输入!" & "
<br/>
1"
2
3else
4
5set rs=server.CreateObject("ADODB.Recordset")
6
7rs.Open "select * from info where ID='" & trim(Request.Form("txtID"))
8& "'" ,"DSN=sqlsales;UID=sa;",3,3
9
10'rs.Open "select * from info where ID=" & chr(34) & "yuaiwu" & chr
11(34) ,"DSN=sqlsales;UID=sa;",3,3
12
13if rs.RecordCount <>0 then
14
15Response.Write "此用户已经登记,请选择别的用户名:"
16
17else
18
19dim fld(7)
20
21dim value(7)
22
23fld(0)="ID"
24
25fld(1)="name"
26
27fld(2)="PWD"
28
29fld(3)="Email"
30
31fld(4)="address"
32
33fld(5)="phone"
34
35fld(6)="post"
36
37fld(7)="sfz"
38
39value(0)=Request.Form("txtID")
40
41value(1)=Request.Form("txtname")
42
43value(2)=Request.Form("txtpwd")
44
45value(3)=Request.Form("txtEmail")
46
47value(4)=Request.Form("txtadd")
48
49value(5)=Request.Form("txtphone")
50
51value(6)=Request.Form("txtPost")
52
53value(7)=Request.Form("txtSFZ")
54
55rs.AddNew fld,value
56
57rs.Update
58
59end if
60
61rs.Close
62
63end if
64
65end if
66
1<html>
2<head>
3<meta content="Microsoft Visual Studio 6.0" name="GENERATOR"/>
4</head>
5<body bgcolor="oldlace">
6<p align="center"><font color="midnightblue" size="6">会 员 申 请</font></p>
7<p>
8<form action="registry.asp" method="post">
9<table border="1" cellpadding="0" cellspacing="0" width="100%">
10<tr>
11<td bgcolor="bisque">用户名</td>
12<td><input id="txtID" name="txtID" style="HEIGHT: 22px; WIDTH: 275px"/>**</td></tr>
13<tr>
14<td bgcolor="bisque">密码</td>
15<td><input id="password1" name="txtPWD" style="HEIGHT: 22px; WIDTH: 274px" type="password"/>**</td></tr>
16<tr>
17<td bgcolor="bisque">确认</td>
18<td><input id="password2" name="txtPWD1" style="HEIGHT: 22px; WIDTH: 275px" type="password"/>**</td></tr>
19<tr>
20<td bgcolor="bisque">姓名</td>
21<td><input id="text2" name="txtname" style="HEIGHT: 22px; WIDTH: 274px"/>**</td></tr>
22<tr>
23<td bgcolor="bisque">身份证号码</td>
24<td><input id="text3" name="txtSFZ" style="HEIGHT: 22px; WIDTH: 274px"/></td></tr>
25<tr>
26<td bgcolor="bisque">Email</td>
27<td><input id="text4" name="txtEmail" style="HEIGHT: 22px; WIDTH: 273px"/></td></tr>
28<tr>
29<td bgcolor="bisque">联系地址:</td>
30<td><input id="text5" name="txtAdd" style="HEIGHT: 22px; WIDTH: 272px"/>**</td></tr>
31<tr>
32<td bgcolor="bisque">邮政编码:</td>
33<td><input id="text6" name="txtPost" style="HEIGHT: 22px; WIDTH: 270px"/>**</td></tr>
34<tr>
35<td bgcolor="bisque">联系电话:</td>
36<td><input id="text5" name="txtPhone" style="HEIGHT: 22px; WIDTH: 270px"/></td></tr>
37</table></form></p>
38<p align="center"><input id="submit1" name="cmdSubmit" type="submit" value="确" 认=""/><input id="reset1" name="cmdCancel" type="reset" value="取消"/></p>
39<p><font color="orangered">请注意:</font></p>
40<ul>
41<li><font color="orangered">带有 ** 号的栏目是必须填写的,其他的栏目可以不
42填</font>
43<li><font color="orangered">以上信息应如实填写,以便我们能与您取得及时的联
44系</font></li></li></ul>
45<p> </p>
46</body></html>
这个登录界面和大多数网上的登录新用户类似。
小结:
几个程序都做了一个简要地说明,当然,程序做地非常简单,还有很多功能没有
或有待完美,但它却示范了一个简单的范例,在此仅供大家参考。如果大家有兴趣,
可以把上面的程序试一下,祝大家成功!