0% found this document useful (0 votes)
3 views

Shopping cart tasklist

The document outlines the design and functionality of an online shopping cart application, including the home page, registration page, and login page, with specific HTML and JavaScript code for form validation. It describes the database structure for users, products, cart, and sales report, detailing the fields and types for each table. Additionally, it explains the process of adding products to the cart, displaying cart information, and checking out, applicable to various product categories.

Uploaded by

Chit Chagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Shopping cart tasklist

The document outlines the design and functionality of an online shopping cart application, including the home page, registration page, and login page, with specific HTML and JavaScript code for form validation. It describes the database structure for users, products, cart, and sales report, detailing the fields and types for each table. Additionally, it explains the process of adding products to the cart, displaying cart information, and checking out, applicable to various product categories.

Uploaded by

Chit Chagan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Shopping cart

Home page:

Design this page with basic html tags using divisions.


Registration page:

Design this page using html tags by using textboxes, dropdown list, text area, and
button.

Here insert the values in to the database table ‘users’

Database: users

Field Type Null Default Comments


uid int(11) No
fname varchar(30) No
lname varchar(20) Yes NULL
uname varchar(30) No
password varchar(30) No
contact varchar(20) No
address varchar(500) No
Field Type Null Default Comments
email varchar(100) Yes NULL
payment_option varchar(200) No
dob date Yes NULL
type varchar(1) No
gender varchar(1) Yes NULL
phno varchar(20) Yes NULL

Field Type Null Default Comments


cid int(11) No
cname varchar(20) No
Form validation:

Code:
<script language="JavaScript">
function doRegister(){

var valid=true;
var errorMsg = "";

var unamecheck=new RegExp("^[a-zA-Z0-9_\\d]+$","g");


// var datecheck=new RegExp("^[{2}0-9");
/*var value1=new RegExp("^[a-zA-Z'-._\\d]+$","g");
var value2=new RegExp("[a-zA-Z\\d]+$","g");//no special chars
var value3=new RegExp("^[a-zA-Z\\d.]+$","g");//no spaces,no special
chars(^ for space)
var value4=new RegExp("[\\d]+$");//no letters
var value5=new RegExp("[a-zA-Z\\d.]+$","g");//no special chars except
dot
if(!value.match(value1))
{alert("please enter valid details");return valid;}

*/

var name=document.rform.fname.value;
var namecheck = new RegExp("^[a-zA-Z0-9\\d]+$","g");

if(name == "")
{
errorMsg += "\nNAME: Provide your first name\n";
}

else if(name.length<3 || name.length >30)


{

errorMsg += "\nNAME: Name lenght MAX 30 MIN 3 Chars\n";


}

else if(!name.match(namecheck))
{

errorMsg += "\nNAME: Your name should not contain any special


characters\n";

var phone = document.rform.contact.value;


if(phone == "")
{

errorMsg += "\nPHONE: Enter phone no.\n";


}
else if(isNaN(phone))
{

errorMsg += "\nPHONE: Enter valid phone no.\n";


}

var email = document.rform.email.value;

var apos=document.rform.email.value.indexOf("@");

var dotpos=document.rform.email.value.lastIndexOf(".")

if(email=="")
{

errorMsg += "\nEMAIL: Provide your emailid\n";


}
else if((apos<1)||((dotpos-apos)<2))
{
errorMsg += "\nEMAIL: Provide valid emailid\n";
}

var address = document.rform.address.value;


if(address == "")
{

errorMsg += "\nADDRESS: Enter address\n";


}

var username=document.rform.uname.value;
var password=document.rform.password.value;
var repassword=document.rform.rpassword.value;

if(username==""||username.length < 6||username.length > 20)


{
errorMsg += "\nUSERNAME: Your Username must be at least 6
characters\n";

}
else if(!username.match(unamecheck))
{
errorMsg += "\nUSERNAME: Your username should not contain any
special characters except UNDERSCORE and should start with alphabet\n";
}

if (password.length < 6||password.length > 20)


{
errorMsg += "\nPASSWORD: Password should be atleast 6 characters
and atmost 20 characters\n";

}
if((password.search("'"))>=0)
{
errorMsg+="\nPASSWORD: Please remove apostrophe from your
Password!\n";

if(password!=repassword)
{
errorMsg += "\nPASSWORDS: Passwords not matching\n";
}
if (errorMsg != "")
{
alert(errorMsg);
return false;
}
else
{

return true;
}
}
</script>

Login page:

Design this page with textbox & button.

Login to the application with the username & password in the ‘users’ table.
Login form validation:

Code:
<script language="JavaScript">
function doLogin(){

if(document.lform.uname.value=="" || document.lform.password.value==""){
alert("Please Provide username and password");
return false;
}
else{
return true;
}
}
</script>
In this application online shopping cart we can buy the products from the following
categories.

 Automobiles
 Electronic & computers
 Home appliances
 Jewelry
 Mobiles & cameras
 Toys & gifts

Automobiles:
Here when we click on the 1st category based on the category id it gets the details
and display.

We are getting the product details from ‘products’ table.

Here we are selecting all fields from products table where cid=?

Here we are providing value to the’?’.

Each & every category have a unique id.

When u click on the link add to cart the products are added to your cart.

Here we are displaying product name, price & quantity.

Cart information
Here we are inserting the product information in to the database table ‘cart’by
using insert query.

Keeping the values in the result set and displays the (product name, price, quantity
& total).

If we want to delete any product from the cart we can delete based on “id”
<%while(rs.next()){%>

<tr>
<td><%=rs.getString("pname")%></td> <td><%=rs.getString("price")
%></td><td><%=rs.getInt("qty")%></td><td><%=rs.getString("total")%></
td><td>&nbsp;&nbsp;<a href="delcart.jsp?id=<%=rs.getInt("id")
%>">delete</a></td>
</tr>

<%}%>

Here we have two options

Want to buy more?

Or

Proceed to check out

If we click on the link “want to buy more” again the process continues as before.

If we click on check out we will get the total amount of our purchased products by
selecting all products from table ‘cart’ where uid=”?”

Now taking all the values from cart table and insert into ‘salesreport’ table and
caliculate the grand total of all the products.

Database table: cart

Field Type Null Default Comments


id int(11) Yes NULL
pid int(11) No
uid int(11) No
pname varchar(50) No
price varchar(30) No
Field Type Null Default Comments
qty int(11) No
total varchar(30) No

Products

Field Type Null Default Comments


pid int(11) No
cid int(11) No
pname varchar(30) No
mrp varchar(10) Yes NULL
discount varchar(3) Yes NULL
imagename varchar(300) Yes NULL
brand varchar(20) Yes NULL
mfd date Yes NULL

Salesreport:

Field Type Null Default Comments


pid int(11) No
uid int(11) No
pname varchar(50) No
price varchar(20) No
qty int(11) No
total varchar(30) No

#this process is same for all the categories of products in the above list.
Electronic & computers
Home appliances
Mobiles & camera

You might also like