标题:[求助]购物车问题
只看楼主
xue
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-5-6
 问题点数:0 回复次数:7 
[求助]购物车问题
请各位兄弟姐妹帮帮忙,我做的购物车只是实现了购物的功能.而当不同的用户进入购物时,用的都是一个购物车,若想不同的用户拥有自己的购物车,该怎样实现?
搜索更多相关主题的帖子: 购物车 兄弟 姐妹 用户 
2005-05-06 16:19
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
用ip地址控制一下

例如:session("ip")=request.servervariables("remote_addr")

[此贴子已经被作者于2005-5-6 17:21:53编辑过]



2005-05-06 17:19
xue
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-5-6
得分:0 
好象不行啊,..
2005-05-06 18:13
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
得分:0 
购物车保存在Session里就不会有这个问题了

天津网站建设 http://www./
2005-05-06 20:02
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
SESSION都不一样
怎么会不能呢?

2005-05-07 11:25
xue
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-5-6
得分:0 
我是用session保存了用户的购物信息的啊,但是购物车不分用户啊!!每个用户进去用的是同一个购物车啊....
2005-05-07 15:44
xue
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-5-6
得分:0 

下面是购物车的代码,其中plist.asp是将用户选购商品的ID添加进商品列表中. <%@ LANGUAGE="VBSCRIPT" %> <!--#include file="plist.asp" --> <!--#include file="connections/xue.asp" --> <% strspbh = Request("spbh") if ((len(trim(strspbh)) = 0) or (strspbh = "undefined")) then strCheck = "no" end if

ProductList = Session("ProductList") Products = Split(Request("spbh"), ", ") For I=0 To UBound(Products) shangpin Products(I), ProductList Next Session("ProductList") = ProductList

Head="您所选购的商品如下" ProductList = Session("ProductList") If Len(ProductList) =0 Then Response.Redirect "nothing.asp" response.end end if

If Request("MySelf") = "Yes" Then ProductList = "" Products = Split(Request("spbh"), ", ") For I=0 To UBound(Products) shangpin Products(I), ProductList Next Session("ProductList") = ProductList End If If Len(ProductList) = 0 Then Response.Redirect "nothing.asp" response.end end if set rs=server.createobject("adodb.recordset") sql = "Select * From Product" sql = sql & " Where Product_Id In (" & ProductList & ")" rs.open sql,conn,3,3 %> <html>

<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>购物车</title> <link href="ct.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .ct1 { font-family: "宋体", Verdana; font-size: 14px; font-style: normal; font-weight: normal; color: #333333; } .aa { font-family: "宋体", Verdana; font-size: 16px; color: #ef2e75; } .ss { font-family: "宋体", Verdana; font-size: 12px; color: #ef2e75; } .ll { border: 1pt dashed #CCCCCC; } .zz { font-family: "宋体", Verdana; font-size: 16px; color: #ff6600; font-weight: bold; } .ll2 { border: 1pt solid #CCCCCC; }

.sp { FONT-SIZE: 9pt; FILTER: DropShadow(color=#000000, OffX=1, OffY=1, Positive=1); COLOR: #000000; LINE-HEIGHT: 17px } .ct2 { font-family: "宋体", Verdana; font-size: 16px; color: #FF99FF; } .td2 { FONT-SIZE: 9pt; COLOR: #666666; LINE-HEIGHT: 20px } .style10 {color: #333333} .style12 {font-size: 10pt; color: #ef2e75; } --> </style> <link rel="stylesheet" type="text/css" href="style.css"> </head> <script language="Javascript"> //函数名:fucCheckNUM //功能介绍:检查是否为数字 //参数说明:要检查的数字 //返回值:1为是数字,0为不是数字 function fucCheckNUM(NUM) { var i,j,strTemp; strTemp="0123456789"; if ( NUM.length== 0) return 0 for (i=0;i<NUM.length;i++) { j=strTemp.indexOf(NUM.charAt(i)); if (j==-1) { //说明有字符不是数字 return 0; } } //说明是数字 return 1; }

function clean() { window.location.href="clear.asp" } </script> <SCRIPT language=javascript id=clientEventHandlersJS> <!-- function form1_onsubmit() { newprice="sl" & rs("Product_Id") if ((fucCheckNUM(document.FORM1.newprice.value)==0) ) { alert ("会员价有非法字符,请填写正确会员价。"); document.FORM1.newprice.focus(); return false; } //--> } </SCRIPT> <body topmargin="5">

<table width="80%" border="0" cellspacing="0"> <tr> <td width="80%" valign="top"><p align="center">  </p> <p align="center"> <font class="style12"><%=Head%></font></p> <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript"><!-- function GW_Form1(theForm) { var checkOK = "0123456789-"; var checkStr = theForm.<%="sl" & rs("Product_Id")%>.value; var allValid = true; var decPoints = 0; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } allNum += ch; } if (!allValid) { alert(在"请输入正确的商品数量!" 域中,只能输入4个字符。); theForm.<%="sl" & rs("Product_Id")%>.focus(); return (false); } return (true); } //--></script><!--webbot BOT="GeneratedScript" endspan --><form Action="gouwuche.asp" Method="POST" name="GW_Form1" id="GW_Form1" onsubmit="return GW_Form1(this)"> <input type="hidden" name="MySelf" value="Yes"> <div align="center"><center> <table border="0" cellspacing="1" width="550" class=main bgcolor="#666666"> <tr bgcolor="#006699"> <td align="center" width="77" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">商品编号</font></td> <td align="center" width="170" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">商品名称</font></td> <td width="67" height="22" align="center" bgcolor="#ffffff" class="style10">单价</td> <td align="center" width="75" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">数量</font></td> <td align="center" width="70" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">购买</font></td> <td align="center" width="72" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">总计</font></td> </tr> <% Sum = 0 While Not rs.EOF Quatity = CInt( Request( "sl" & rs("Product_Id")) ) If Quatity <= 0 Then Quatity = CInt( Session(rs("Product_Id")) ) If Quatity <= 0 Then Quatity = 1 End If Session(rs("Product_Id")) = Quatity Sum = Sum + ccur(rs("Product_NPrice")) * Quatity %> <tr> <td class="td2" align="center" width="77" bgcolor="#ffffff"><%=rs("Product_ID")%> </td> <td class="td2" align="center" width="170" bgcolor="#ffffff"><%=rs("Product_Name")%> </td> <td class="ss" align="center" width="67" bgcolor="#ffffff"><%=rs("Product_NPrice")%> </td> <td class="ss" align="center" width="75" bgcolor="#ffffff"><input Name="<%="sl" & rs("Product_Id")%>" id="<%="sl" & rs("Product_Id")%>" Value="<%=Quatity%>" Size="3"> <input name="B1" type="submit" id="B1" value="修改"></td> <td class="ss" Align="center" width="70" bgcolor="#ffffff"><input name="spbh" type="CheckBox" id="spbh" value="<%=rs("Product_Id")%>" checked> </td> <td class="ss" Align="center" width="72" bgcolor="#ffffff"><%=ccur(rs("Product_NPrice"))*Quatity%>.00元 </td> </tr> <% rs.MoveNext Wend %> <tr> <td Align="center" ColSpan="6" bgcolor="#ffffff"><font Color="Red" class="ss">费用总计: <%=Sum%>.00元</font></td> </tr> </table> </center></div><blockquote> <p align="center"> &nbsp;&nbsp;&nbsp; <input type="button" value="继续购物" name="B2" onclick="window.close();" style="font-size: 9pt">&nbsp;&nbsp;&nbsp; <input type="button" value="订单取消" name="B3" OnClick="clean()" style="font-size: 9pt">&nbsp;&nbsp;&nbsp; <input type="button" value="去收银台" onClick="window.open('ment.asp',window.close(), 'Sample', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=610,height=600,left=100,top=100')" name="b4"> </blockquote> </form> </td></tr></table> </div> <% rs.close conn.close %> </body> </html> 这个问题,到底哪里该改下???

2005-05-07 15:47
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 

2005-05-08 09:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-17461-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.079627 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved