Nothing Special   »   [go: up one dir, main page]

Ecommerce Website

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 49
At a glance
Powered by AI
The document discusses the development of an ecommerce website as a college project. It describes the various sections and features of the website.

The purpose of the ecommerce website is to act as a platform connecting sellers/businesses to potential customers.

The intended audiences of the website are customers/consumers looking to shop for clothing apparel online as well as businesses to reach out to target audiences and make profits.

Ecommerce Website

Project Report

Name: Angana Das


Department: CSE Section: B
Year: 3rd Semester: 6th
Roll No: 81
University Roll No: 430119020081
Subject: Software Engineering Lab
Subject Code: CS693

1
ACKNOWLEDGEMENT
I would like to convey my heartfelt gratitude to Anukul Maity Sir for his tremendous direction and
assistance in the completion of my project.

This project would not have materialized without his help and guidance. His useful advice and
suggestions were really helpful to me during the project’s completion. In this aspect, I am eternally
grateful to him.

Thank You,

Angana Das.

2
DATE SL.N TOPIC PAGE
O NO .
17.02.222 1. INTRODUCTION 1

24.02.22 2. DATA FLOW DIAGRAM AND ER 2-4


DIAGRAM

17.03.22 3. USER CASES

7.04.22 4. TEST CASES

21.04.22 5. CODING

12.05.22 6. CONCLUSION AND REFERENCE

3
1.INTRODUCTION
This is a project about creating an ecommerce website. It is a B2C ecommerce platform, that is, the
website sells from an established business to a different consumer. The website can be used to list items
for sale from the admin side as well as buy the listed items from the customer side.

There is a separate panel and account for each customer while there is only one panel for the admin as
the website is administered by one business account only.

1.1 PURPOSE
There purpose of this website is used to work as a platform that connects the seller or business to a
customer base. The admin can put up their products on the website for viewing and the customer can
sort through them to see the items they required.

A search option is present at the top right-hand corner so the customer can easily find the items they
require or surf through the website as per their convenience.

1.2 INTENDED AUDIENCE


The intended audience for this project is the various customers or consumers who are looking to shop
for clothing apparel online. The business or admin can also use it to reach out to target audience and
make a profit for their business.

4
3.USER CASES

3.1 USER RELATED CASES


3.1.1Visit a site
The very first page on visiting a site is the registration page. The user is required to enter their name,
email, phone number, password of choice and a security question from a drop-down list to register.
After all this information has been entered the user can click on ‘sign up’ button to register.

The database is immediately updated and the user is shown a text letting them know that the
registration has been successful. There is also a log in option for users who already have a registered
account to log into the website.

3.1.2 Log in Page


In the log in page the user has to enter their registered email id and password and click on submit
button to log in. This will take them to the home page.

5
3.1.3 Search for Items
The user can view all the available items on their home page or they can use the search bar on the top
right-hand corner to look for the required items. The search bar can search for items based on partial
terms as well as full terms.

Once the user finds the item there is a add to cart option on the right hand side of the item that will add
the product to the customers cart.

3.1.4Edit or Remove items from the cart


The user can change the quantity or the even remove a product from the cart entirely from the My Cart
option from the header. The page also displays the details of the items in the cart such as the name,
price, quantity and the total cost of the items.

6
3.1.5 Change Details
In the change details page the user can change the details they have typed in during the registration
earlier. The changeable details include the mobile number, password, security question and address.

Upon clicking on the button on the header the page will go to a different page where the header
displays the various details that can be changed.

To go back to the home page, a back button is available on the top left-hand corner.

3.1.6 Contact the Admin


For any feedback or complain the user can use the message page to send their text using their
registered email for the purpose.

7
3.2 ADMIN CASES
3.2.1 Log in
The admin uses the same log in page as the user using the user id ‘admin@email.com’ and password
‘admin’. This takes the admin to the welcome page of the website to see the various options and
updates.

The admin header displays the various functions the admin can perform such as adding new product,
viewing any updates etc.

3.2.2 Add and Edit Product


The admin can change the values of the existing product such as the price, name, category etc.

8
The admin can also add new products. The product id is displayed at the top of the page and
automatically updated every time a new product is added.

The added or changed product is updated on the database connected.

3.2.3 Messages Received


The admin can check for any message or contact the users might have made through the ‘Message
Received’ page.

3.2.4 Orders Received


The admin can check the status of all the orders made my any customer as well as process any pending
order or cancel any orders.

9
10
6.TEST CASES
Cas Test Case Description Test Data Expected Result Actual Result Pass/Fail
e ID.
1 Register Page: Check response 1.Email:abci@email.com Registration As Expected PASS
when trying to register with Name: abc abc unsuccessful.
same data twice. Password:abc
Message shown
2.Email:abci@email.com “Something went
Name: abc abc wrong! Try Again”
Password:abc

2 Register Page: Check response Email:xyz@email.com Registration As Expected PASS


when trying to register with Name:xyz successful.
new data. Password:xyz
Message shown
“Successfully
Registered!”
3. Log in Page: Check response Email:xyz@email.com Login As Expected PASS
when trying to log in with Password:123 Unsuccessful.
wrong data.

4. Log in Page: Check response Email:xyz@email.com Login Successful. As Expected PASS


when trying to log in with Password:xyz
correct data.

11
5. CODING
The coding was done on Eclipse IDE using HTML and CSS for the front end and JSP for the back end, i.e.,
to perform the various actions on the website.

The code for the various Actions on the website is as follows:

5.1 SIGN UP ACTION


<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String name=request.getParameter("name");
String email=request.getParameter("email");
String mobileNumber=request.getParameter("mobileNumber");
String securityQuestion=request.getParameter("securityQuestion");
String answer=request.getParameter("answer");
String password=request.getParameter("password");
String address="";
String city="";
String state="";
String country="";
try
{
Connection con = ConnectionProvider.getCon();
PreparedStatement ps=con.prepareStatement("insert into users
values(?,?,?,?,?,?,?,?,?,?)");
ps.setString(1,name);
ps.setString(2,email);
ps.setString(3,mobileNumber);
ps.setString(4,securityQuestion);
ps.setString(5,answer);
ps.setString(6,password);
ps.setString(7,address);
ps.setString(8,city);
ps.setString(9,state);
ps.setString(10,country);
ps.executeUpdate();
response.sendRedirect("signup.jsp?msg=valid");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("signup.jsp?msg=invalid");
}

%>

12
5.2 LOG IN ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=request.getParameter("email");
String password=request.getParameter("password");
if("admin@gmail.com".equals(email) && "admin".equals(password))
{
session.setAttribute("email", email);
response.sendRedirect("adminHome.jsp");
}
else
{
int z=0;
try
{
Connection con = ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where
email='"+email+"' and password='"+password+"'");
while(rs.next())
{
z=1;
session.setAttribute("email",email);
response.sendRedirect("home.jsp");
}
if(z==0)
response.sendRedirect("login.jsp");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("login.jsp?msg=invalid");
}
}

13
%>
5.3 ADD TO CART ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String product_id=request.getParameter("id");
int quantity=1;
int product_price=0;
int product_total=0;
int cart_total=0;
int z=0;
try
{

Connection con = ConnectionProvider.getCon();


Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from product where
id='"+product_id+"'");
while(rs.next()){
product_price=rs.getInt(4);
product_total=product_price;
}
ResultSet rs1=st.executeQuery("select * from cart where
product_id='"+product_id+"' and email='"+email+"' and address is NULL");
while(rs1.next())
{

cart_total=rs1.getInt(5);
cart_total=cart_total+product_total;
quantity=rs1.getInt(3);
quantity=quantity+1;
z=1;
}
if(z==1){
st.executeUpdate("update cart set
total='"+cart_total+"',quantity='"+quantity+"' where product_id='"+product_id+"' and
email='"+email+"' and address is NULL");
response.sendRedirect("home.jsp?msg=exist");
}
if(z==0){
PreparedStatement ps=con.prepareStatement("insert into
cart(email,product_id,quantity,price,total) values(?,?,?,?,?)");
ps.setString(1,email);
ps.setString(2,product_id);
ps.setInt(3,quantity);
ps.setInt(4,product_price);
ps.setInt(5,product_total);
ps.execute();
response.sendRedirect("home.jsp?msg=added");
}}
catch(Exception e){

14
System.out.println(e);
response.sendRedirect("home.jsp?msg=invalid"); } %>

5.4 CANCEL ORDER ACTION


<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String id=request.getParameter("id");
String email=request.getParameter("email");
String status="Cancel";

try{
Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
st.executeUpdate("update cart set status='"+status+"' where
product_id='"+id+"' and email='"+email+"' and address is not NULL ");
response.sendRedirect("ordersReceived.jsp?msg=cancel");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("ordersReceived.jsp?msg=wrong");

%>

15
5.5 ADD NEW PRODUCT ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String id=request.getParameter("id");
String name=request.getParameter("name");
String category=request.getParameter("category");
String price=request.getParameter("price");
String active=request.getParameter("active");

try
{
Connection con = ConnectionProvider.getCon();
PreparedStatement ps=con.prepareStatement("insert into product
values(?,?,?,?,?)");
ps.setString(1,id);
ps.setString(2,name);
ps.setString(3,category);
ps.setString(4,price);
ps.setString(5,active);
ps.executeUpdate();
response.sendRedirect("addNewProduct.jsp?msg=done");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("addNewProduct.jsp?msg=wrong");
}

%>

16
5.6 ADD OR CHANGE ADDRESS ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String address=request.getParameter("address");
String city=request.getParameter("city");
String state=request.getParameter("state");
String country=request.getParameter("couontry");

try{
Connection con=ConnectionProvider.getCon();
PreparedStatement ps=con.prepareStatement("update users set address=?,
city=?, state=?,country=? where email=? ");
ps.setString(1,address);
ps.setString(2,city);
ps.setString(3,state);
ps.setString(4,country);
ps.setString(5,email);
response.sendRedirect("addChangeAddress.jsp?msg=valid");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("addChangeAddress.jsp?msg=invalid");

%>

17
5.7 ADD NEW ADDRESS BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="changeDetailsHeader.jsp" %>
<%@include file="footer.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/changeDetails.css" />
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<title>Add or Change Address</title>
</head>
<body>
<%
String msg=request.getParameter("msg");
if("valid".equals(msg))
{
%>
<h3 class="alert">Address Successfully Updated !</h3>
<%}%>
<%
if("invalid".equals(msg))
{
%>
<h3 class="alert">Some thing Went Wrong! Try Again!</h3>
<%} %>
<%
try{
Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where email='"+email+"'");
while(rs.next())
{
%>
<form action="AddChangeAddressAction.jsp" method="post">
<h3>Enter Address</h3>
<input class="input-style" type="text" name="address" value="<%=rs.getString(7)
%>"placeholder="Enter Address" required>

<hr>
<h3>Enter city</h3>
<input class="input-style" type="text" name="city" value="<%=rs.getString(8)
%>"placeholder="Enter City" required>

<hr>
<h3>Enter State</h3>
<input class="input-style" type="text" name="state" value="<%=rs.getString(9)
%>"placeholder="Enter State" required>

<hr>
<h3>Enter country</h3>
<input class="input-style" type="text" name="country" value="<%=rs.getString(10)
%>"placeholder="Enter Country" required>

18
<hr>
<button class="button" type="submit">Save<i class='far fa-arrow-alt-circle-
right'></i></button>
</form>
<%
}
}
catch(Exception e)
{System.out.print(e);
}%>
</body>
<br><br><br>
</html>

19
5.8 ADD NEW PRODUCT BY ADMIN
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="adminHeader.jsp" %>
<%@include file="../footer.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/addNewProduct-
style.css" />
<title>Add New Product</title>
</head>
<body style= "background: #E8B6F0">
<%
String msg=request.getParameter("msg");
if("done".equals(msg))
{
%>
<h3 class="alert">Product Added Successfully!</h3>
<%}%>
<%
if("invalid".equals(msg))
{
%>
<h3 class="alert">Some thing went wrong! Try Again!</h3>
<%} %>

<%
int id=1;
try{

Connection con = ConnectionProvider.getCon();


Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select max(id)from product");
while(rs.next())
{
id=rs.getInt(1);
id=id+1;
}
}
catch(Exception e)
{}
%>
<form action="AddNewProductAction.jsp" method="post">
<h3 style="color: #821470; borer:#ACA4AB ;">Product ID:<%out.println(id); %> </h3>
<input type="hidden" name="id" value="<%out.println(id); %>">

<div class="left-div" style="color:#821470 ;">


<h3>Enter Name</h3>
<input class="input-style" type="text" name="name" placeholder="Enter Name of
Product" required>
<hr>

20
</div>

<div class="right-div">
<h3 style="color:#821470 ;">Enter Category</h3>
<input class="input-style" type="text" name="category" placeholder="Enter Category
of Product" required>

<hr>
</div>

<div class="left-div">
<h3 style="color:#821470 ;">Enter Price</h3>
<input class="input-style" type="number" name="price" placeholder="Enter Price of
Product" required>

<hr>
</div>

<div class="right-div" style="color:#821470 ;">


<h3>Active</h3>
<select class="input-style" name="active">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>

<hr>
</div>
<button class="button">Save<i class='far fa-arrow-alt-circle-right'></i></button>
</form>
</body>
<br><br><br>
</body>
</html>

21
5.9 ADMIN HEADER
<%@page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/home-style.css" />
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-
awesome.min.css">
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
</head>
<!--Header-->
<br>
<div class="topnav sticky">
<% String email=session.getAttribute("email").toString(); %>
<center><h2>Fashion Stopper Admin Panel</h2></center>
<a href="addNewProduct.jsp">Add New Product <i class='fas fa-plus-
square'></i></a>
<a href="allProductEditProduct.jsp">All Products & Edit Products <i
class='fab fa-elementor'></i></a>
<a href="messagesReceived.jsp">Messages Received <i class='fas fa-
comment-alt'></i></a>
<a href="ordersReceived.jsp">Orders Received <i class="fas fa-
archive"></i></a>
<a href="cancelOrders.jsp">Cancel Orders <i class='fas fa-window-
close'></i></a>
<a href="deliveredOrders.jsp">Delivered Orders <i class='fas fa-
dolly'></i></a>
<a href="logout.jsp">Logout <i class='fas fa-share-square'></i></a>
</div>
<br>
<!--table-->

22
5.10 CHANGE DETAILS BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="changeDetailsHeader.jsp" %>
<%@include file="footer.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/changeDetails.css" />

<title>Change Details</title>
<style>
hr
{width:70%;}</style>
</head>
<body>
<%
try{
Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where email='"+email+"'");
while(rs.next())
{
%>
<h3>Name: <%=rs.getString(1) %> </h3>
<hr>
<h3>Email: <%=rs.getString(2) %></h3>
<hr>
<h3>Mobile Number: <%=rs.getString(3) %></h3>
<hr>
<h3>Security Question: <%=rs.getString(4) %></h3>
<hr>
<br>
<br>
<br>
<%
}
}
catch(Exception e)
{System.out.print(e);
}%>
</body>
</html>

23
5.11 ADMIN HOME
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="adminHeader.jsp" %>
<%@include file="../footer.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home</title>
<style>
h3
{
color: black;
text-align: center;
}
</style>
</head>
<body style="background: #E8B6F0 ">
<div style="color: white; text-align: center; font-size: 30px;">All Products & Edit
Products <i class='fab fa-elementor'></i></div>
<%
String msg=request.getParameter("msg");
if("done".equals(msg))
{
%>
<h3 class="alert">Product Successfully Updated!</h3>
<%}%>
<%
if("wrong".equals(msg))
{
%>
<h3 class="alert">Some thing went wrong! Try again!</h3>
<%} %>

<table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Category</th>
<th scope="col"><i class="fa fa-inr"></i> Price</th>
<th>Status</th>
<th scope="col">Edit <i class='fas fa-pen-fancy'></i></th>
</tr>
</thead>
<tbody>
<% try{

24
Connection con = ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from product");
while(rs.next())
{

%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><i class="fa fa-inr"></i><%=rs.getString(4)%></td>
<td><%=rs.getString(5) %></td>
<td><a href="editProduct.jsp?id=<%=rs.getString(1)%>">Edit <i class='fas
fa-pen-fancy'></i></a></td>
</tr>
<%
}
}
catch(Exception e)
{
System.out.println(e);
}
%>
</tbody>
</table>
<br>
<br>
<br>

</body>
</html>

25
5.12 CANCEL ORDER BY ADMIN
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="adminHeader.jsp" %>
<%@include file="footer.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/ordersReceived-
style.css" />
<title>Home</title>
<style>
.th-style
{ width: 25%;}
</style>
</head>
<body>
<div style="color: white; text-align: center; font-size: 30px;">Cancel Orders <i
class='fas fa-window-close'></i></div>

<table id="customers">
<tr>
<th>Mobile Number</th>
<th scope="col">Product Name</th>
<th scope="col">Quantity</th>
<th scope="col"><i class="fa fa-inr"></i> Sub Total</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Country</th>
<th scope="col">Order Date</th>
<th scope="col">Expected Delivery Date</th>
<th scope="col">Payment Method</th>
<th scope="col">T-ID</th>
<th scope="col">Status</th>
</tr>
<%
try
{

Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from cart inner join product
where cart.product_id=product.id and cart.orderDate is not NULL and
cart.status='Cancel'");
while(rs.next())
{
%>

<tr>
<td><%=rs.getString(10) %></td>
<td><%=rs.getString(17) %></td>

26
<td><%=rs.getString(3) %></td>
<td><i class="fa fa-inr"></i> <%=rs.getString(5) %></td>
<td><%=rs.getString(6) %></td>
<td><%=rs.getString(7) %></td>
<td><%=rs.getString(8) %></td>
<td><%=rs.getString(9) %></td>
<td><%=rs.getString(11) %></td>
<td><%=rs.getString(12) %></td>
<td><%=rs.getString(13) %></td>
<td><%=rs.getString(14) %></td>
<td><%=rs.getString(15) %></td>
</tr>
<%
}
}
catch(Exception e)
{System.out.print(e);
}%>
</table>
<br>
<br>
<br>

</body>
</html>

27
5.13 CHANGE DETAILS HEADER
<%@page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/home-style.css" />
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-
awesome.min.css">
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
</head>
<!--Header-->
<br>
<div class="topnav sticky">
<center><h2>Change Details<i class= "fa fa-edit"></i></h2></center>
<%String email=session.getAttribute("email").toString(); %>
<h2><a href="home.jsp"><i class='fas fa-arrow-circle-
left'>Back</i></a></h2>
<h2><a href="">Your Profile(<%out.println(email); %>) <i class='fas fa-
user-alt'></i></a></h2>
<a href=changePassword.jsp>Change Password <i class='fas fa-key'></i></a>
<a href="addChangeAddress.jsp">Add or change Address <i class='fas fa-
map-marker-alt'></i></a>
<a href="changeSecurityQuestion.jsp">Change Security Question <i
class="fa fa-repeat"></i></a>
<a href="changeMobileNumber.jsp">Change Mobile Number <i class='fas fa-
phone'></i></a>
</div>
<br>
<!--table-->

28
5.14 CHANGE MOBILE NUMBER BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="changeDetailsHeader.jsp" %>
<%@include file="footer.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/changeDetails.css" />
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<title>Message Us</title>
</head>
<body>
<%
String msg=request.getParameter("msg");
if("done".equals(msg))
{
%>
<h3 class="alert">Your Mobile Number successfully changed!</h3>
<%}%>
<%
if("wrong".equals(msg))
{
%>
<h3 class="alert">Your Password is wrong!</h3>
<%} %>

<form action="ChangeMobileNumberAction.jsp" method="post">

<h3>Enter Your New Mobile Number</h3>


<input class="input-style" type="number" name="mobileNumber"
placeholder="Enter New Mobile Number"required >

<hr>
<h3>Enter Password (For Security)</h3>
<input class="input-style" type="password" name="password" placeholder="Enter
Password"required >

<hr>
<button class="button" type="submit">Save<i class='far fa-arrow-alt-circle-
right'></i></button>
</form>
</body>
<br><br><br>
</html>

29
5.15 CHANGE MOBILE NUMBER ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String mobileNumber=request.getParameter("mobileNumber");
String password=request.getParameter("password");
int check=0;
try{
Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where
email='"+email+"' and password='"+password+"' ");
while(rs.next())
{
check=1;
st.executeUpdate("update users set
securityQuestion='"+mobileNumber+"' where email='"+email+"'");
response.sendRedirect("changeMobileNumber.jsp?msg=done");

}
if(check==0)
response.sendRedirect("changeMobileNumber.jsp?msg=wrong");

}
catch(Exception e)
{
System.out.println(e);
}

%>

30
5.16 CHANGE PASSWORD ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="changeDetailsHeader.jsp" %>
<%@include file="footer.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/changeDetails.css" />
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<title>Message Us</title>
</head>
<body>
<%
String msg=request.getParameter("msg");
if("notmatch".equals(msg))
{
%>
<h3 class="alert">New password and Confirm password does not match!</h3>
<%}%>
<%
if("wrong".equals(msg))
{
%>
<h3 class="alert">Your old Password is wrong!</h3>
<%} %>
<%
if("done".equals(msg))
{
%>
<h3 class="alert">Password change successfully!</h3>
<%} %>
<%
if("invalid".equals(msg))
{
%>
<h3 class="alert">Some thing went wrong! Try again!</h3>
<%} %>

<form action="ChangePasswordAction.jsp" method="post">


<h3>Enter Old Password</h3>
<input class="input-style" type="password" name="oldPassword" placeholder="Enter
Old Password" required>

<hr>
<h3>Enter New Password</h3>
<input class="input-style" type="password" name="newPassword" placeholder="Enter
New Password" required>

<hr>
<h3>Enter Confirm Password</h3>
<input class="input-style" type="password" name="confirmPassword"
placeholder="Confirm Password" required>

31
<hr>
<button class="button" type="submit">Save<i class='far fa-arrow-alt-circle-
right'></i></button>
</form>
</body>
<br><br><br>
</html>

32
5.17 CHANGE PASSWORD ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String oldPassword=request.getParameter("oldPassword");
String newPassword=request.getParameter("newPassword");
String confirmPassword=request.getParameter("confirmPassword");
if(!confirmPassword.equals(newPassword))
response.sendRedirect("changePassword.jsp?msg=nomatch");
else
{
int check=0;
try{
Connection con=ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where
email='"+email+"' and password='"+oldPassword+"' ");
while(rs.next())
{
check=1;
st.executeUpdate("update users set password='"+newPassword+"'
where email='"+email+"'");
response.sendRedirect("changePassword.jsp?msg=done");

}
if(check==0)
response.sendRedirect("changePassword.jsp?msg=wrong");

}
catch(Exception e)
{
System.out.println(e);
}
}

%>

33
5.18 REMOVE FROM CART BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String id=request.getParameter("id");
String incdec=request.getParameter("quantity");
try
{

Connection con = ConnectionProvider.getCon();


Statement st=con.createStatement();
st.executeUpdate("delete from cart where email='"+email+"' and
product_id='"+id+"' and address is NULL");
response.sendRedirect("myCart.jsp?msg=removed");

}
catch(Exception e)
{

System.out.println(e);

%>

34
5.19 HEADER OF USER
<%@page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="${pageContext.request.contextPath}/home-style.css" />

<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-
awesome.min.css">
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
</head>
<!--Header-->
<br>
<div class="topnav sticky">
<% String email=session.getAttribute("email").toString(); %>
<center><h2>Fashion Stopper</h2></center>
<h2><a href=""><%out.println(email); %><i class='fas fa-user-
alt'></i></a></h2>
<a href="home.jsp">Home<i class="fa fa-institution"></i></a>
<a href="myCart.jsp">My Cart<i class='fas fa-cart-arrow-down'></i></a>
<a href="myOrders.jsp">My Orders <i class='fab fa-elementor'></i></a>
<a href="changeDetails.jsp">Change Details <i class="fa fa-edit"></i></a>
<a href="messageUs.jsp">Message Us <i class='fas fa-comment-alt'></i></a>
<a href="about.jsp">About <i class="fa fa-address-book"></i></a>
<a href="logout.jsp">Logout <i class='fas fa-share-square'></i></a>
<div class="search-container">
<form action="searchHome.jsp" method="post">
<input type="text" name="search" placeholder="search">
<button type="submit"><i class='fa fa-search'></i></button>
</form>

<i class="fa fa-search"></i>

</div>
</div>
<br>
<!--table-->

35
5.20 INCREASE OR DECREASES QUANTITY IN CART BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String id=request.getParameter("id");
String incdec=request.getParameter("quantity");
int quantity=0;
int price=0;
int total=0;
int final_total=0;

try
{

Connection con = ConnectionProvider.getCon();


Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from cart where email='"+email+"' and
product_id='"+id+"' and address is NULL");
while(rs.next())
{
price=rs.getInt(4);
total=rs.getInt(5);
quantity=rs.getInt(3);
}

if(quantity==1 && incdec.equals("dec"))


{
response.sendRedirect("myCart.jsp?msg=notpossible");
}
else if(quantity!=1 && incdec.equals("dec"))
{
total=total-price;
quantity=quantity-1;
st.executeUpdate("update cart set total='"+total+"',
quantity='"+quantity+"' where email='"+email+"' and product_id='"+id+"' and address
is NULL");
response.sendRedirect("myCart.jsp?msg=dec");
}
else
{
total=total+price;
quantity=quantity+1;
st.executeUpdate("update cart set total='"+total+"',
quantity='"+quantity+"' where email='"+email+"' and product_id='"+id+"' and address
is NULL");
response.sendRedirect("myCart.jsp?msg=inc");
}

}
catch(Exception e)
{

36
System.out.println(e); }%>

5.21 STYLE.CSS
body {
font-family: "Open Sans", sans-serif;
line-height: 1.25;
background-color: #E8B6F0;
}
a
{
text-decoration: none;
}
.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
}

table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
/*margin-left: 5%;*/
table-layout: fixed;
}

table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}

table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}

table th,
table td {
padding: .625em;
text-align: center;
}

table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}

@media screen and (max-width: 600px) {


table {

37
border: 0;
}

table caption {
font-size: 1.3em;
}

table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}

table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}

table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}

table td:last-child {
border-bottom: 0;
}
}

/*Header Css*/
* {box-sizing: border-box;}

body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}

38
.topnav {
overflow: hidden;
background-color: #e9e9e9;
}

.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

.topnav a:hover {
background-color: #ddd;
color: black;
}

.topnav a.active {
background-color: #E8B6F0;
color: white;
}

.topnav .search-container {
float: right;
}

.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}

.topnav .search-container button {


float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
}

.topnav .search-container button:hover {


background: #ccc;
}

@media screen and (max-width: 600px) {


.topnav .search-container {

39
float: none;
}
.topnav a, .topnav input[type=text], .topnav .search-container button {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}

}
/*footer*/
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color:#ccc;
color:black;
text-align: center;
}

.h2222 {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #B224C8;
color: white;
}

40
5.22 SEARCH BY USER
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="header.jsp" %>
<%@include file="footer.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home</title>
</head>
<body>
<div style="color: white; text-align: center; font-size: 30px;">Home <i class="fa
fa-institution"></i></div>
<table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Category</th>
<th scope="col"><i class="fa fa-inr"></i> Price</th>
<th scope="col">Add to cart <i class='fas fa-cart-plus'></i></th>
</tr>
</thead>
<tbody>
<%
int z=0;
try{
String search=request.getParameter("search");
Connection con = ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from product where name like
'%"+search+"%' or category like '%"+search+"%' and active='Yes'");
while(rs.next())
{
z=1;
%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><i class="fa fa-inr"></i><%=rs.getString(4)%></td>
<td><a href="AddToCartAction.jsp?id=<%=rs.getString(1)%>">Add to cart <i
class='fas fa-cart-plus'></i></a></td>
</tr>
<%
}
}
catch(Exception e)
{
System.out.println(e);
}

41
%>

</tbody>
</table>
<%if(z==0){ %>
<h1 style="color:white; text-align: center;">Nothing to show</h1>
<%} %>
<br>
<br>
<br>
<div class="footer">
<p>All right reserved by BTech Days</p>
</div>

</body>
</html>

42
5.23 FORGOT PASSWORD
<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="${pageContext.request.contextPath}/signup-style.css" />

<title>ForgotPassword</title>
</head>
<body>
<div id='container'>
<div class='signup'>
<form action="ForgotPasswordAction.jsp" method="post">
<input type="email" name="email" placeholder="Enter Your Email" required >
<input type="number" name="mobileNumber" placeholder="Enter Mobile Number"
required >
<select name="securityQuestion" required>
<option value="What was your first car model?">What was your first car model?
</option>
<option value="what is your hobby?">what is your hobby?</option>
<option value="What is the name of the town you were born?">What is the name
of the town you were born?</option>
<option value="What is the name of your favourite author?">What is the name of
your favourite author?</option>
</select>
<input type="text" name="answer" placeholder="Answer Security Question"required
>
<input type="password" name="newPassword" placeholder="Enter New Password"
required >
<input type="submit" value="save">
</form>
<h2><a href="">Login</a></h2>
</div>
<div class='whyforgotPassword'>
<%
String msg=request.getParameter("msg");
if("done".equals(msg))
{
%>
<h1>Password Changed Successfully!</h1>
<%}%>
<%
if("invalid".equals(msg))
{
%>
<h1>Some thing Went Wrong! Try Again !</h1>
<%} %>
<h2>Online Shopping</h2>
<p>The Online Shopping System is the application that allows the users to shop
online without going to the shops to buy them.</p>
</div>
</div>
</body>

43
</html>

5.24 FORGOT PASSWORD ACTION


<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=request.getParameter("email");
String mobileNumber=request.getParameter("mobileNumber");
String securityQuestion=request.getParameter("securityQuestion");
String answer=request.getParameter("answer");
String newPassword=request.getParameter("newPassword");
int check=0;
try
{
Connection con = ConnectionProvider.getCon();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from users where
email='"+email+"' and mobileNumber='"+mobileNumber+"' and
securityQuestion='"+securityQuestion+"' and answer='"+answer+"'");
while(rs.next())
{
check=1;
st.executeUpdate("update users set password='"+newPassword+"'
where email='"+email+"'");
response.sendRedirect("forgotPassword.jsp?msg=done"); }
if(check==0)
response.sendRedirect("forgotPassword.jsp?msg=invalid");

}
catch(Exception e)
{
System.out.println(e);
}

%>

44
5.25 MESSAGE US
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%@include file="header.jsp" %>
<%@include file="footer.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${pageContext.request.contextPath}/messageUs.css" />

<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<title>Message Us</title>
</head>
<body>
<div style="color: white; text-align: center; font-size: 30px;">Message Us <i
class='fas fa-comment-alt'></i></div>
<%
String msg=request.getParameter("msg");
if("valid".equals(msg))
{
%>
<h3 style="text-align:center; color:yellow;">Message successfully sent. Our team will
contact you soon!</h3>
<%}%>
<%
if("invalid".equals(msg))
{
%>
<h3 style="text-align:center; ">Some thing Went Wrong! Try Again!</h3>
<%} %>

<form action="MessageUsAction.jsp" method="post">


<input class="input-style" type="text" name="subject"
placeholder="Subject"required >
<hr>
<textarea class="input-style" name="body" placeholder="Enter Your
Text"required></textarea>
<hr>
<button class="button" type="submit">Send <i class='far fa-arrow-alt-circle-
right'></i></button>
</form>

<br><br><br>
</body>
</html>

45
5.26 MESSAGE US ACTION
<%@ page import="Project.ConnectionProvider"%>
<%@ page import="java.sql.*"%>
<%
String email=session.getAttribute("email").toString();
String subject=request.getParameter("subject");
String body=request.getParameter("body");

try{
Connection con=ConnectionProvider.getCon();
PreparedStatement ps=con.prepareStatement("insert into
message(email,subject,body) values(?,?,?) ");
ps.setString(1,email);
ps.setString(2,subject);
ps.setString(3,body);
ps.executeUpdate();
response.sendRedirect("messageUs.jsp?msg=valid");

}
catch(Exception e)
{
System.out.println(e);
response.sendRedirect("addChangeAddress.jsp?msg=invalid");

%>

46
5.27 FOOTER
<div class="footer">
<link rel="stylesheet" href="${pageContext.request.contextPath} /footer.css" />

<footer style= "background: white">


<a href="https://www.facebook.com/xyz/" class="fo fo-facebook"
target="blank">f</a>
<a href="https://twitter.com/xyz/" class="fo fo-twitter"
target="blank">t</a>
<a href="https://www.instagram.com/xyz/" class="fo fo-instagram"
target="blank">i</a>
<a href="https://in.linkedin.com/xyz/" class="fo fo-linkedln"
target="blank">in</a>
<a href="mailto:studywriterr@gmail.com" class="fo fo-mail"
target="blank">G</a>
</footer>
<p>All Right Reserved @ Angana Das</p>
</div>

5.28 LOGOUT
<%
session.invalidate();
response.sendRedirect("login.jsp");
%>

47
6.1 CONCLUSION
Ecommerce is a growing field and everyday new websites and platforms are popping up. By making this
website I gained an insight into the tough competition of this vast and interesting field.

This website can be useful to both the customer as it is very simple and easy to navigate and also for the
administrator of the website as it is very easy and versatile.

48
6.2 REFERENCE
This project has been completed thanks to the help from these websites:

 GeekForGeeks
 HTML Color Codes
 W3Schools
 Wikipedia

 Software Engineering: A Practitioner's Approach (For providing the theoretical concepts


of software engineering)

49

You might also like