当前位置: 首页 > 图文教程 > 网络编程 > ASP > 简单购物车教程

ASP
ASP漏洞集-跨站Script攻击和防范
利用JSP的思想来做ASP
asp的19个基本技巧
自定义aspnet_client的位置
编码的风格和如何设置调试代码
RS.GETROWS使用详解
Adodb.Stream 组件的使用说明
在ASP.Net中实现RSA加密
关于水晶报表10 的字报表数据填充和显示
DataList里套DataGrid,DataBind
ASP.NET验证控件详解
ASP网站漏洞解析及黑客入侵防范方法
产生一个密码,并记录到数据库,然后发送给用户
ASP内置对象 Request对象 详解
ASP 中 DateDiff 函数详解
几个常用的小函数
在记录集中加入判断使之灵活
会员系统“找回密码”的制作方法
一个分页代码例子
常见的错误及其解决方法

ASP 中的 简单购物车教程


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 16 ::
收藏到网摘: n/a

数据库字段
表:pro_talbe:
id 产品编号
proname 产品名称
simages 产品小图 
表o_rder:
id 订单编号
p_roid 产品编号
m_um 产品数量
d_time 订购时间
表co_table:
id 客户编号
nn_ame 客户姓名
tt_el 联系电话
ee_m_ail 客户邮箱
+++++++++++++++++++++++
index.asp源码
+++++++++++++++++++++++

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT * FROM pro_table"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="583" border="0" cellspacing="0" cellpadding="0">
<% 
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
%>
<tr> 
<td width="140"><%=(Recordset1.Fields.Item("id").Value)%></td>
<td width="171"><%=(Recordset1.Fields.Item("proname").Value)%></td>
<td width="272"><%=(Recordset1.Fields.Item("simages").Value)%></td>
<td width="272"><a href="cart.asp?ProductID=<%=(Recordset1.Fields.Item("id").Value)%>&quantity=1">购买</a></td>
</tr>
<% 
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset1.Close()
%>
列出产品,这里有一个要点就是:<a href="cart.asp?ProductID=<%=(Recordset1.Fields.Item("id").Value)%>&quantity=1">购买</a>
这里传递了两个参数:产品ID“ProductID" 数量:“quantity"

+++++++++++++++++++++++++
下面是cart.asp的源码:
+++++++++++++++++++++

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<%
if not IsObject(session("cart")) then
Set session("cart")=CreateObject("Scripting.Dictionary")
end if
Set cart=session("cart")
productID=Cstr(request("productID"))
dim detail(1)
detail(0)=Int(request("quantity"))
if request("productID")<>"" then
if cart.Exists(productID) then
cart.Remove(productID)
end if
cart.add productID,detail
end if
keys=cart.keys
items=cart.items
set session("cart")=cart
%>

<HTML>
<HEAD>
<TITLE>浙江广源印刷包装有限公司</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK 
href="index/index.css" type=text/css rel=stylesheet>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<tr> 
<td width="100%" valign="top"> <br>
<table border="2" width="100%" cellspacing="0"&nbs