Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

shopping cart in asp/cookies/anything

Posted on 2000-03-22
15
Medium Priority
?
274 Views
Last Modified: 2013-12-25
Of any of the options above, which is the easiest to create a simple shopping cart? Security is not needed. But the ability to keep track of the products added is required.

How can this be done?
0
Comment
Question by:java_kevin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
  • +1
15 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 2649373
asp session variables are an easy way but cookies must be enabled on the client.

you could add products to a session array.....

do you want an example

are ypou using a database.

in perl cookies are your best bet.. you can use dbi which is nice and easy
0
 

Author Comment

by:java_kevin
ID: 2649471
asp session var means using asp? Cookies are used here too? session array means...?

An eg will be best, but prefer to have it only when the method is decided.

Yes, using a database for the items tat can be added.

Do you mean that, regardless of the method used, cookies are necessary? i mean, asp need cookies, perl same too?

DBI is...?
0
 
LVL 10

Expert Comment

by:makerp
ID: 2649486
your best bet is to use perl as your cgi langauage.

use cookies as an intermediate data store

and dbi to talk to your db.

i have a excelent dbi example and some cgi examples using cookies
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 

Author Comment

by:java_kevin
ID: 2651819
Adjusted points from 200 to 250
0
 

Author Comment

by:java_kevin
ID: 2651820
ok. how about using asp?
wat's dbi?

waiting for the examples... if more pts r needed, feel free to ask :)
0
 
LVL 10

Expert Comment

by:makerp
ID: 2652530
asp is nice and easy. you have the advantage of sessions variables so you can store the users purchases in these. sessions varaibles are variables which you create in scripts at run time but they are visible in other scripts. the session variables will die when the users session times out or when you explicetly null them. a session times out when the user had not interacted with your site for a set amount of time, the default is 20 minutets.

if you use perl then cookies can be used as your intermediate data store.

both approaches will need you to interact with a database. asp provides you with ADO which is very easy to use and perl provides you with dbi.

tell me what language you wish to use and i can provide loads of examples. asp will make your life easier thinking about it.
0
 
LVL 10

Expert Comment

by:makerp
ID: 2652533
dbi by the way is the Data Base Interface for perl
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2654936
if you are looking at fast setup, then check out this free PERL based program that is lite, yet convinient.


DCShop is a complete shopping cart system for your e-commerce web site.
you can Download and test drive DCShop at...
http://www.dcscripts.com/dcshop.shtml
0
 

Author Comment

by:java_kevin
ID: 2656491
I'll try asp.

Hope to see the code soon.. I need it urgently.
0
 
LVL 1

Expert Comment

by:mafweb
ID: 2657379
well, if you're still interested in a perl solution without cookies, this might be for you:
Each time a customer adds an article, you update a variable called a_<ID>, i.e. for one piece of article 007, you'd set (for example, with an textfield in your form) a_007 to 1.
then you use the following code to deliver those variables to the subsequent page:

print "<form action=...>";

$i=0;

if($ENV{'REQUEST_METHOD'} eq 'GET')
   {
    $Data = $ENV{'QUERY_STRING'}
   }
  else
   {
    read(STDIN, $Data, $ENV{'CONTENT_LENGTH'});
   }

  @Forms = split(/&/, $Data);
  foreach $Field (@Forms)  
   {
    ($name, $value) = split(/=/, $Field);  
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<!--(.|\n)*-->//g;      
    if ($name=~/a_/) { #got an article here
      print "<input type=hidden name=$name value=$value>";
    }
    $Form[$i] = $name;  
    $i = $i + 1;
    $Form[$i] = $value;  
    $i = $i + 1;
   }
0
 

Author Comment

by:java_kevin
ID: 2657516
mafweb, but is this perl or asp? If possible, I'd like to try asp first.
0
 
LVL 1

Expert Comment

by:mafweb
ID: 2658828
sorry, java_kevin, but this is perl. Maybe there is a way to do it similarly in asp, but I do not know it
0
 
LVL 10

Accepted Solution

by:
makerp earned 1000 total points
ID: 2660209
<%
' this is a simple example of a shopping cart. you will need to collect user details, credit card
' etc. hope this gives you some ideas, the best thing to do before steaming ahead is to design
' your database and then develop you scripts around that
'
' our form has called the script
IF(Request("name") <> "")THEN
     ' if count has not been created then create it and zero it
     IF(Session("count") = "")THEN
          Session("count") = 0
     END IF
     ' if we are finished
     IF(Request("finished") = "Y")THEN
            ' get the last entry
            Session("product_"&Session("count")) = Request("name")
            Session("amount_"&Session("count")) = Request("amount")
            Session("count") = Session("count") + 1
            ' tell the user what they ordered
            %><H1>You placed orders for</H1><%
            FOR i = 0 TO Session("count") - 1
                  %><%=Session("product_"&i)%> : <%=Session("amount_"&i)%><BR><%
            NEXT
            ' save it to our very simple database
            %>Saving details<%
            Set cnn1 = Server.CreateObject("ADODB.Connection")
            cnn1.open "DSN=your_dsn_you_set_up_in_ODBC_control_panel"
            FOR i = 0 TO Session("count") - 1
                 cnn1.Execute("INSERT INTO orders (name,amount) VALUES ('"&Session("product_"&i&"',"&Session("amount_"&i)&")")
            NEXT
          ' now zero all of our session variables, alternativly we could call the session.Abandon
            FOR i = 0 TO Session("count") - 1
                 Session("product_"&i) = ""
                 Session("amount_"&i) = ""
                 Session("count") = ""
            NEXT
     ELSE ' the user has NOT selected the finished check box
            ' add a product to our session
            Session("product_"&Session("count")) = Request("name")
            Session("amount_"&Session("count")) = Request("amount")
            Session("count") = Session("count") + 1
            Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
     END IF
' else splash out our very simple order form
ELSE
%>
     <HR>
     Enter an item
     <FORM METHOD=POST ACTION=<%=Request.ServerVariables("SCRIPT_NAME")%>>
           product : <INPUT TYPE=TEXT NAME=name><BR>
           amount : <INPUT TYPE=TEXT NAME=amount><BR>
           <INPUT TYPE=CHECKBOX NAME=finished VALUE='Y'>Are You Finished</INPUT><BR>
           <BR>
           <INPUT TYPE=SUBMIT VALUE='Submit Query'>
     </FORM>
<%
END IF
%>
0
 
LVL 10

Expert Comment

by:makerp
ID: 2660213
any questions then ask
0
 

Author Comment

by:java_kevin
ID: 2667519
thanks.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question