Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help creating a very basic shopping basket for a website.

Posted on 2007-11-14
6
Medium Priority
?
310 Views
Last Modified: 2013-11-07
HI all,

I need some help creating a very basic shopping basket on a website. Basically all that is needed to happen is you have a list of items with a quantity box, the visitor can fill in the amount of each item they want, click 'send' or 'order' and the amount is collated into a very basic basket which then has fields for the customer to fill in contact details then click 'order' or 'send' again and all that does is send an email to a recipient.
That is it! Nothing more, nothing less, issue being I don't know how to do it  lol

Not sure on the best method to employ to do this, have been told ASP.net is good, so I've downloaded and installed Microsoft Visual Web Developer - which seems cool.

I'm OK with HTML and CSS, but have little to no experience with ASP, or any other programming language so any help would be greatly appreciated. I can't see this being majorly difficult, just awkward for someone not knowing the details behind anything other than HTML or CSS.

Thanks in advance.


0
Comment
Question by:Nicola_Bourne
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Aurora27
ID: 20283336
If you are doing ASP.NET, then you can actually store the *item numbers* if they are unique in some session variables and then build the info. abt items ordered everytime the shopping cart pages comes up..based on that...

If you have a user logged in for that, then simply store it in a db table and reference it anytime you want too. Like,w hen they add an Item, add to ShoppingCart table for that user and then pull it up..its like anyother master/details tables logic.

CT.
0
 

Author Comment

by:Nicola_Bourne
ID: 20283399
Bare in mind I don't know any ASP, I don't have the need for users to create accounts or log in etc, I would guess that it is simple a case of visiting the site, seeing that you want say 2 of item A, 3 of item B and 6 of item C, click GO and then type in your name, number and address and click SEND. Maybe not even that complicated. Simplicity is the key here :) (Mainly because I am quite simple!!!  lol)


0
 
LVL 37

Expert Comment

by:samtran0331
ID: 20284335
>>I'm OK with HTML and CSS, but have little to no experience with ASP, or any other programming language

That being the case, I'd suggest you pick a technology and find open source e-commerce project.
That way you don't have to start from scratch.

Since you need "simple"...you might not even have to modify anything in the projects except the visuals.

ASP.Net:
http://www.asp.net/community/projects/
*the second and third projects both have cart functionality.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:Nicola_Bourne
ID: 20288342
I have had a look through some examples on the web last night, and employed something I found into my site, only I'm having a little trouble getting it to work properly!

Basically the example that I found on the web is a simple form that has 3 text boxes and 2 buttons.
[Name], [EMail] and [Text].
The two buttons are [Send] and [Reset].

The sample code basically sends the information in each of the text boxes to a set email address within the code.

This is great, only the sample code doesn't include any syntax for SMTP server authentication, such as username and password.

So I scnaned the web again for such syntax's and stuck them in, I get zero Errors, warnings or messages from the Visual Web Developer app I'm using to write this stuff, but it fails to work when I'm testing it. It carries straight to the end of the code where it prints a message to the screen stating that "Sending email failed".

Again, I'm very new to this, so I appologise in advance for my sheer level of ignorance!

 [DEFAULT.ASPX.CS]

using System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
    #region  "Send email"
    protected void btnSendmail_Click(object sender, EventArgs e)
    {
        // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
        // System.Net.Mail.SmtpClient is the alternate class for this in 2.0
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();

        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

            // You can specify the host name or ipaddress of your server
            // Default in IIS will be localhost
            smtpClient.Host = "xxx.xx.3.98";
            smtpClient.Credentials = new System.Net.NetworkCredential("**********",
                                     "**********");
                       
            //Default port will be 25
            smtpClient.Port = 25;

            //From address will be given as a MailAddress Object
            message.From = fromAddress;

            // To address collection of MailAddress
            message.To.Add("username@domain.co.uk");
            message.Subject = "TEST";

            // CC and BCC optional
            // MailAddressCollection class is used to send the email to various users
            // You can specify Address as new MailAddress("admin1@yoursite.com")
            //message.CC.Add("admin1@yoursite.com");
            //message.CC.Add("admin2@yoursite.com");

            // You can specify Address directly as string
            //message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
            //message.Bcc.Add(new MailAddress("admin4@yoursite.com"));

            //Body can be Html or text format
            //Specify true if it is html message
            message.IsBodyHtml = false;

            // Message body content
            message.Body = txtMessage.Text;

            // Send SMTP mail
            smtpClient.Send(message);

            lblStatus.Text = "Email successfully sent.";
        }
        catch (Exception ex)
        {
            lblStatus.Text = "Send Email Failed.<br>" + ex.Message;
        }
    }
    #endregion

----------------------
I have now changed the last bit of the code above from:

       lblStatus.Text = "Send Email Failed.<br>" + ex.Message;

to:

       lblStatus.Text = ex.ToString();

Which results in this load of 'stuff' being outputted to the screen, which I simply do no understand! lol

       
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.btnSendmail_Click(Object sender, EventArgs e) in c:\Documents and Settings\Dale\My Documents\Visual Studio 2005\WebSites\WebSite3\Default.aspx.cs:line 58

using System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
 
public partial class _Default : System.Web.UI.Page
{
    #region  "Send email"
    protected void btnSendmail_Click(object sender, EventArgs e)
    {
        // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
        // System.Net.Mail.SmtpClient is the alternate class for this in 2.0
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();
 
        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
 
            // You can specify the host name or ipaddress of your server
            // Default in IIS will be localhost 
            smtpClient.Host = "xx.xx.15.102";
            smtpClient.Credentials = new System.Net.NetworkCredential("login",
                                     "password");
                        
            //Default port will be 25
            smtpClient.Port = 25;
 
            //From address will be given as a MailAddress Object
            message.From = fromAddress;
 
            // To address collection of MailAddress
            message.To.Add("username@domain.co.uk");
            message.Subject = "TEST";
 
            // CC and BCC optional
            // MailAddressCollection class is used to send the email to various users
            // You can specify Address as new MailAddress("admin1@yoursite.com")
            //message.CC.Add("admin1@yoursite.com");
            //message.CC.Add("admin2@yoursite.com");
 
            // You can specify Address directly as string
            //message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
            //message.Bcc.Add(new MailAddress("admin4@yoursite.com"));
 
            //Body can be Html or text format
            //Specify true if it is html message
            message.IsBodyHtml = false;
 
            // Message body content
            message.Body = txtMessage.Text;
 
            // Send SMTP mail
            smtpClient.Send(message);
 
            lblStatus.Text = "Email successfully sent.";
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.ToString();
        }
    }
    #endregion
 
    #region "Reset"
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtName.Text = "";
        txtMessage.Text = "";
        txtEmail.Text = "";
    }
    #endregion
}
 
 
 
 	
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.btnSendmail_Click(Object sender, EventArgs e) in c:\Documents and Settings\Dale\My Documents\Visual Studio 2005\WebSites\WebSite3\Default.aspx.cs:line 58

Open in new window

0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 2000 total points
ID: 20288517
This site has just about everything you need to know about sending email in ASP.Net
http://www.systemnetmail.com/faq/4.1.aspx
http://www.systemnetmail.com/faq/2.4.aspx

use the "Home" link on the left to go back to the main page if you have other email questions...
0
 

Author Closing Comment

by:Nicola_Bourne
ID: 31409218
Thanks very much for your help.
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

916 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