Solved

shopping cart in asp/cookies/anything

Posted on 2000-03-22
15
235 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
  • 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
 

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 250 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now