Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Location
    Holland
    Posts
    16

    Angry Unanswered: 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>

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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....

  3. #3
    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?

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    this is an array and a loop all in one,.... from your own code....
    ' 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •