If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Sessions and how to transfer data??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-04, 16:26
EvE EvE is offline
Registered User
 
Join Date: Aug 2002
Location: Holland
Posts: 16
Angry Sessions and how to transfer data??

URGENT HELP NEEDED!!!

I created a webshop but I do not like the fact that people first have to register before shopping. I therefor created a page called sessionCart. But how do I get this data(the actual order) into my access database?

Here's the page(sessionCart.asp):

<%
' Define Constants
CONST CARTPID = 0
CONST CARTPNAME = 1
CONST CARTPPRICE = 2
CONST CARTPQUANTITY = 3

' Get The Shopping Cart
IF NOT isArray( Session( "cart" ) ) THEN
DIM localCart( 4, 20 )
ELSE
localCart = Session( "cart" )
END IF

' Get Product Information
productID = TRIM( Request( "pid" ) )
productName = TRIM( Request( "productName" ) )
productPrice = TRIM( Request( "productPrice" ) )

' Add Item to cart
IF productID <> "" THEN
foundIT = FALSE
FOR i = 0 TO UBOUND( localCart )
IF localCart( CARTPID, i ) = productID THEN
localCart( CARTPQUANTITY, i ) = localCart( CARTPQUANTITY, i ) + 1
foundIT = TRUE
EXIT FOR
END IF
NEXT
IF NOT foundIT THEN
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, i ) = "" THEN
localCart( CARTPID, i ) = productID
localCart( CARTPNAME, i ) = productName
localCart( CARTPPRICE, i ) = productPrice
localCart( CARTPQUANTITY, i ) = 1
EXIT FOR
END IF
NEXT
END IF
END IF

' Update Shopping Cart Quantities
IF Request( "updateQ" ) <> "" THEN
FOR i = 0 TO UBOUND( localCart, 2 )
newQ = TRIM( Request( "pq" & localCart( CARTPID, i ) ) )
IF newQ = "" or newQ = "0" THEN
localCart( CARTPID, i ) = ""
ELSE
IF isNumeric( newQ ) THEN
localCart( CARTPQUANTITY, i ) = newQ
END IF
END IF
NEXT
END IF


' Update Session variable with Array
Session( "cart" ) = localCart
%>
<html>
<head><title>Session Shopping Cart</title>
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="white">

<center>
<font face="Arial" size=3 color="darkgreen"> <b><span class="bodytekst">Winkelwagen:</span></b>
</font>
<%
orderTotal = 0
%>
<form method="post" action="sessionCart.asp">
<input name="updateQ" type="hidden" value="1">
<table bgcolor="lightyellow" border=1 cellpadding=4 cellspacing=0 class="bodytekst">
<tr>
<th bgcolor="#CCCCCC">Artikel</th>
<th bgcolor="#CCCCCC">Prijs</th>
<th bgcolor="#CCCCCC">Aantal</th>
</tr>
<%
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, i ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, i ) * localCart( CARTPQUANTITY, i ) )
%>
<tr bgcolor="#FFFFFF">
<td> <%=Server.HTMLEncode( localCart( CARTPNAME, i ) )%> </td>
<td> <%=formatCurrency( localCart( CARTPPRICE, i ) )%> </td>
<td>
<input name="pq<%=localCart( CARTPID, i )%>" type="text" size=4 value="<%=localCart( CARTPQUANTITY, i )%>">

</td>
</tr>

<%
END IF
NEXT
%>
<tr bgcolor="#CCCCCC">
<td colspan=2 align=right>Verzendkosten in &euro;</td>
<td> 6,00</td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan=2 align=right> <b>Totaalbedrag in &euro;</b></td>
<td> <%=formatCurrency( orderTotal + 6)%> </td>
</tr>
<tr>
<td colspan=3>
<table border=0 bgcolor="#FFFFFF">
<tr>
<td align="right">
<input type="submit" value="Verwerk wijzigingen">
</td>
</form>
<form method="post" action="checkout.asp">
<td>
<input type="submit" value="Afrekenen">
</td>
</form>
<form action="default.asp">
<td>
<input type="submit" value="Verder winkelen">
</td>
</form>
</tr>
</table>
</td>
</tr>
</table>


</center>

</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 04-20-04, 19:37
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
So you want to add the session("cart") to your access db once they have registered?? yes??

If so, once they have registered you need to check that array and loop through it performing inserts for each record you find....
Reply With Quote
  #3 (permalink)  
Old 04-21-04, 16:17
EvE EvE is offline
Registered User
 
Join Date: Aug 2002
Location: Holland
Posts: 16
OK, But how???

I haven't got a clue about arrays and loops. Could you be more specific?
Reply With Quote
  #4 (permalink)  
Old 04-21-04, 18:45
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
this is an array and a loop all in one,.... from your own code....
Quote:
' Update Shopping Cart Quantities
FOR i = 0 TO UBOUND( localCart, 2 )
newQ = TRIM( Request( "pq" & localCart( CARTPID, i ) ) )
IF newQ = "" or newQ = "0" THEN
localCart( CARTPID, i ) = ""
ELSE
IF isNumeric( newQ ) THEN
localCart( CARTPQUANTITY, i ) = newQ
END IF
END IF
NEXT
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On