Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-23-2007, 11:37 AM
WebProWorld New Member
 

Join Date: Nov 2007
Posts: 12
kumiko RepRank 0
Unhappy asp problem with shopping cart

hallo all..i got some problem in using the session in ASP. i hope u all can guide me in detail.
i have a form, inside got 3 drop down and one text box. and got one Add button. wat i wan to do is:
after fill in the value for this form, then click the add button and it will display the value in the 2nd page. the data hasnt insert into the database yet. then when user click on continue button in the 2nd page, it can add another new record , etc...until the user click on the FINISH button on the 2nd page, then all the records will insert into DB. it is something similar to the shopping cart ...but i duno how is work?

can someone plz teach me how to keep the record from the form as session? how is it work ..plz help....i need some guide on how to start the coding . im quite new in asp..so i got some problem on how to code it..
thank you
Reply With Quote
  #2 (permalink)  
Old 11-23-2007, 02:20 PM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,396
Dubbya RepRank 3Dubbya RepRank 3Dubbya RepRank 3
Default Re: asp problem with shopping cart

Build a standard form. After submitting the form, check to ensure that you've got some data, set your session variables, then set the value of the form field as the session values. When you've got the data, save it to your database.

Save this as "start.asp"
Code:
<%
 '*************************************************
 ' Check for errors or omissions in submitted forms
 '*************************************************
 if Request.QueryString("err") = "nodata" Then
 	errormessg = "Please enter all data."
 else
	errormessg = ""
 end if
%>
<html>
<head>
<title>My Form Page</title>
</head>
<body>
<p align="center">
<%
 if errormessg <> "" Then
 	Response.Write "<font color=red><b>" & errormessg & "</b></font><br><br>"
 end if
%>
<form name="myform" method="post" action="confirm.asp">
  <select name="select1">
    <option value="">Select One</option>
    <option value="your first option">option 1</option>
    <option value="your second option">option2</option>
  </select><br><br>
  
  <select name="select2">
    <option value="">Choose One</option>
    <option value="option A">option A</option>
    <option value="option B">option B</option>
  </select><br><br>
  
  <select name="select3">
    <option value="">Pick One</option>
    <option value="selected 1a">choose 1a</option>
    <option value="selected 2b">choose 2b</option>
	<option value="selected 3c">choose 3c</option>
  </select><br><br>
  
 <input type="text" name="thetextfield" value="<%=textValue%>" /><br><br>
 <input type="submit" value="Add" />
</form>
</p>
</body>
</html>
Save this as "confirm.asp"
Code:
 <%
 '**********************************************************
 ' Assign some variables and get the form data if it exists.
 '**********************************************************
  showForm = FALSE
  formField1 = Request.Form("select1")
  formField2 = Request.Form("select2")
  formField3 = Request.Form("select3")
  formField4 = Request.Form("thetextfield")
 
  Session("info1") = formField1
  Session("info2") = formField2
  Session("info3") = formField3
  Session("info4") = formField4
  

 '********************************************************
 ' If all fields contain data, show the confirmation form.
 '********************************************************

 if formField1 <> "" AND formField2 <> "" AND formField3 <> "" AND formField4 <> "" Then
     showForm = TRUE
 else
 	 Response.Redirect "start.asp?err=nodata"
 end if
%>

<%if ShowForm Then %>
 <html>
 <head>
 <title>Confirm your selections</title>
 </head>
 <body>
  <h1>Your Selections</h1>
    <p><b>Select Field 1 contained:</b> <%=formField1%></p>
    <p><b>Select Field 2 contained:</b> <%=formField2%></p>
    <p><b>Select Field 3 contained:</b> <%=formField3%></p>
    <p><b>Text Field 1 contained:</b> <%=formField4%></p>
    <p>If this information is correct, press the Continue button.</p>
    <p>If you wish to start over, <a href="start.asp">Go Back To The Form</a></p>
    <form name="confirmationForm" method="post" action="save.asp">
	 <input type="hidden" name="mode" value="save">
     <input type="submit" value="Continue">
    </form>
 </body>
 </html>
<%end if%>
Save this as "save.asp"
Code:
<%
 '**********************************
 ' Check for submitted values again.
 '**********************************
 if Request.Form("mode") = "save" Then
 	formField1 = Session("info1")
 	formField2 = Session("info2")
 	formField3 = Session("info3")
	formField4 = Session("info4")
 else
 	Response.Redirect "start.asp"
 end if

'*******************************
' Database scripting goes here.
' ******************************
' open your database connection object and insert the data.
' close your database connection object.

'**********************************************
' Destroy the sessions after saving information
'**********************************************
 Session.Abandon()
%>
<html>
<head>
<title>Selection Complete</title>
</head>
<body>
  <h1>Thank you.</h1>
  <p>Your selections have been saved.</p>
  <p><a href="start.asp">Return to the form</a></p>
</body>
</html>
This will get you started but be sure to visit the following ASP Sites for some great resources:

ASP 101 - Active Server Pages 101
ASP Free Forums - ASP Help, ASP Tutorials, ASP Programming, ASP Code, ASP Hosting
Forums - ASP.NET Forums
ASP, ASP.NET, SQL and JavaScript articles, tutorials and forums - ASPdev.org
ASP Tutorial
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
  #3 (permalink)  
Old 11-23-2007, 11:50 PM
WebProWorld New Member
 

Join Date: Nov 2007
Posts: 12
kumiko RepRank 0
Unhappy Re: asp problem with shopping cart

halo dubbya, thanx for ur reply..but i m not understand, how is the session add to another session, let say, i have submit the product data for first time and then put in it the shopping cart,but havent insert into DB.then i go back to the product page and submit another porudct again..then in the display shopping cart page, it will add on wat i have order and the price also will increase..how is this work? plz help..thanx..
Reply With Quote
  #4 (permalink)  
Old 11-24-2007, 09:40 PM
WebProWorld New Member
 

Join Date: Nov 2007
Posts: 12
kumiko RepRank 0
Question Re: asp problem with shopping cart

halo..is there anyone can help me how to keep the record in session /cookies and then retrieve each record out and display? plz help tahxn
Reply With Quote
  #5 (permalink)  
Old 11-26-2007, 11:21 AM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,396
Dubbya RepRank 3Dubbya RepRank 3Dubbya RepRank 3
Default Re: asp problem with shopping cart

You can concatenate (add) to the session value thusly:

Code:
<%
TableStart = "<table border=""0"" align=""center""><tr><td>"
RowStart = "<tr><td>"
RowEnd = "</td></tr>"
TableEnd = "</td><tr></table>"

Session("info") = TableStart
Session("info") = Session("info") & "Some data." & RowEnd & vbCrlf
Session("info") = Session("info") & vbTab & RowStart & " Some more data.<br />" & RowEnd & vbCrlf
Session("info") = Session("info") & vbTab & RowStart & " More data still.<br />" & RowEnd & vbCrlf
Session("info") = Session("info") & vbTab & RowStart & " Even more data.<br />" & TableEnd & vbCrlf

Response.Write Session("info")
%>
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
  #6 (permalink)  
Old 11-27-2007, 12:17 AM
WebProWorld New Member
 

Join Date: Nov 2007
Posts: 12
kumiko RepRank 0
Smile Re: asp problem with shopping cart

hello..dubbaya..thanx for guidance and response...i have solved it..thank you very much.. ^^
Reply With Quote
  #7 (permalink)  
Old 11-27-2007, 11:25 AM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,396
Dubbya RepRank 3Dubbya RepRank 3Dubbya RepRank 3
Default Re: asp problem with shopping cart

You're most welcome.

Glad to help.
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


Thread Tools
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cube Cart Shopping Cart roban Google Discussion Forum 2 10-17-2007 10:30 AM
my shopping cart obietemp eCommerce Discussion Forum 7 08-07-2007 02:37 PM
shopping cart system shopping... bricklebrit eCommerce Discussion Forum 6 12-24-2006 08:08 PM
Free shopping cart - Aceflex Cart gretta_001 eCommerce Discussion Forum 0 11-30-2005 04:04 AM
shopping cart jacobwissler eCommerce Discussion Forum 3 06-23-2005 03:19 PM


Search Engine Optimization by vBSEO 3.2.0