Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions

Status
Not open for further replies.

jspuser

Technical User
Apr 12, 2005
3
GB
I am created a shopping cart successfully in servletusing the following SQL "select order_id, name, price, quantity, member_id, quantity*price as sub_total from items, orders where orders.item_id=items.item_id order by order id".

What I would like to be able to do is be able to get the user to click on complete order and the following fields are captured using session and put into the purchase order table after the shopping cart is complete and the order has been paid, an example of information is provided by executing the following SQL:

getRecordToHash( rs, rsHash, aFields );
String flditem_id = (String) rsHash.get("name");
String fldorder_id = (String) rsHash.get("order_id");
String fldprice = (String) rsHash.get("price");
String fldquantity = (String) rsHash.get("quantity");
String fldsub_total = (String) rsHash.get ("sub_total");


cn.execute("insert into purchases (invoice_id, order_id, member_id, item_id, quantity")

select order_id, member_id, item_id, quanity from orders where member-id=" & Session("UserID").

response.write "Thank you for shopping with us"

end.

Sorry some of my knowledge is prelimary ASP but your help would be very much appreciated.


 
I would like to be able to write a JSP capturing the values from the shopping cart and insert this straight into a purchase order table.
 
Example in ASP

dim pnref
dim result
dim respmsg
pnref= getParam("PNREF")
result = getParam("RESULT")
respmsg = getParam("RESPMSG")
response.write "<font color = red>" & respmsg & "</font><br>"
if result = 0 then
cn.execute("insert into invoices (member_id, invoice_id) values (" &
Session("UserID") & ", '" & pnref & "')")
cn.execute("insert into purchases (invoice_id, order_id, member_id, item_id,
quantity) select '" & pnref & "', order_id, member_id, item_id, quantity from orders
where member_id = " & Session("UserID"))
response.write "Thank you for shopping with us.<br> For your records, the
reference number for this transcation is:<font color = red>" & pnref &
"</font><br>"
else
response.write "This transaction was not approved.<br> Please adjust your payment
details and try again."
end if
 
... What is your question? I (and others) prefer to help with failed attempts rather than writing code for people.

Tim
---------------------------
"Your morbid fear of losing,
destroys the light you're using." - Ozzy
 
jspuser,

I see you are a new member to Tek-Tips.
This is a great site, with many helpful members, but we are NOT here to write code for you, or to convert code from ASP to JSP for you. Sometimes, a question might be like "Anyone know how to connect to LDAP" or something, and you might get lucky and have someone post some example code - but generally you should be prepared to at least have attempted something yourself.

An IT professional is expected to lean new technology by reading up on it - if you are an IT professional, I suggest you read the JSP/Servlet section in the link timw gave you, and try to write something yourself. When you have something, and its not working, come back and we will gladly help debug it for you.

Good luck.


--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top