Solved

Help creating a very basic shopping basket for a website.

Posted on 2007-11-14
6
285 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
css, html 6 29
C# code editing and collaboration 3 42
What .NET website keeps me current? 9 29
Adjust the position 3 7
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

708 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

20 Experts available now in Live!

Get 1:1 Help Now