Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“JNANA SANGAMA”, BELAGAVI-590018

A
DBMS Laboratory Mini Project Report On

“SUPERMARKET ONLINE STORE”


SUBMITTED IN PARTIAL FULFILLMENT FOR 5TH SEMESTER
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING

SUBMITTED BY
GHAZALA JAMAL(1JB20CS032)
VINAYA CHOWDHARY(1JB20CS026)

Under the Guidance of:

Guide Name Guide Name


DR BINDIYA M K Dr. RAJATHA
Assoc. Professor Asst. Professor
Dept. of CSE, SJBIT Dept. of CSE, SJBIT

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SJB INSTITUTE OF TECHNOLOGY
BGS HEALTH AND EDUCATION CITY, KENGERI, BENGALURU-560060
KARNATAKA, INDIA.
2022 - 2023
||Jai Sri Gurudev||
Sri Adichunchanagiri Shikshana Trust ®
SJB INSTITUTE OF TECHNOLOGY
BGS Health & Education City, Kengeri, Bengaluru – 60
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE

Certified that the Mini project work entitled “SUPERMARKET MANAGEMENT


SYSTEM” carried out by Ms. GHAZALA JAMAL:1JB20CS032(1JB18IS050) and
Ms. Vinaya Chaudhary
Bearing USN 1JB20CS032 and 1JB20CS026 are bonafide student of SJB Institute of
Technology in fulfilment for 5th Semester DATABASE MANAGEMENT SYSTEM
MINI PROJECT in COMPUTER SCIENCE AND ENGINEERING of the
Visvesvaraya Technological University, Belagavi during the academic year 2022-23.
It is certified that all corrections/suggestions indicated for Internal Assessment have
been incorporated in the report deposited in the departmental library. The mini project
report has been approved as it satisfies the academic requirements in respect of mini
project work prescribed for the said degree.

Signature of Guide Signature of Guide Signature of HOD


Name of the Guide Name of the Guide Dr. Krishna A N
Designation Designation Prof. & HOD
Dept. of CSE, SJBIT Dept. of CSE, SJBIT Dept. of CSE, SJBIT
We would like to express our profound thanks to his Divine Soul Padmabhushan Sri Sri
SriDr. Balagangadharanatha Maha Swamiji and his Holiness Jagadguru Sri Sri Sri
Dr. Nirmalanandanatha Maha Swamiji for providing us the opportunity to pursue my academics in
this esteemed institution.

We would also like to express our profound thanks to Revered Sri Sri Dr. .Prakashnath
Swamiji, Managing Director, SJB Institute of Technology, for his continuous support in providing
amenities to carry out this mini project in this admired institution.

We express our gratitude to Dr. K.V. Mahendra Prashanth, Principal, SJB Institute of
Technology, for providing us excellent facilities and academic ambience; which have helped us in
satisfactory completion of mini project work.

We extend our sincere thanks to Dr. Krishna A.N, Head of the Department, COMPUTER
SCIENCE AND ENGINEERING; for providing us invaluable support throughout the period of mini
project work.

We wish to express heartfelt gratitude to our guide, , Dr. Bindiya MK and Associate Professor ,
Mrs. Rajatha and Assistant Professor , for her valuable guidance, suggestions and
cheerful encouragement during the entire period of this work.

We express my truthful thanks to Dr. Vinod H C, Associate Professor, Dept Information


Science Engineering for his valuable support.

Finally, We take this opportunity to extend our earnest gratitude and respect to our parents,
Teaching & Non-teaching staff of the department, the library staff and all our friends, who have
directly or indirectly supported us during the period of this mini project work.

Regards,
Ghazala Jamal (1JB20CS032)
Vinaya Chaudhary(1JB20CS026)
i
ABSTRACT

The Project Supermarket Management System deals with the automation of supermarket. It
includes both sales and purchase of items. The project Supermarket Management System is
developed with the objective of making the system reliable, easier, fast, and more informative.
There is a lot of reason for the introduction of this project. In the manual System, there are
number of inefficiencies that a salesperson faces. Large records-books have to be maintained
where relevant and irrelevant information has to be stored which is very untidy and clumsy
process. But our System reduces paper works. On the other hand, there are many inherent
problems that exist in any manual system. Usually, they lack efficiency. Less efficiency has a
great impact on the productivity of any human being keeping the data up to date.

The different modules included in our project are administrative module, cart module, products
module, user info module and orders module. Each customer can login with the help of his/her
unique id and password. Products and Orders module contains all the purchase and sales
details. All the payment details will be shown in the Cart module.

II
TABLE OF CONTENTS

Acknowledgment I

Abstract II

Table of Contents III

List of Figures V

List of Tables VI

Chapter 1
Introduction

1.1 Introduction… ...................................................................................................... 1

1.2 Problem State ....................................................................................................... 1

1.3 Scope .................................................................................................................... 1

Chapter 2

Literature Survey

2.1 Traditional File Systems… .................................................................................. 2

2.2 Pros and Cons of the Traditional Approach ......................................................... 2

2.3 Downfall of Traditional Management System ..................................................... 3

2.4 Introduction to the Database Management System ............................................. 4

2.5 Indicative areas for the use of a DBMS ............................................................... 4

2.6 Advantages of a DBMS ....................................................................................... 5

2.7 Components of a DBMS ...................................................................................... 5

Chapter 3

System Requirements

3.1 Hardware Requirements…....................................................................................7

3.2 Software Requirements… .................................................................................... 7

III
Chapter 4

System Design

4.1 Schema Diagram… ........................................................................................... 8

4.2 ER Diagram ...................................................................................................... 9

Chapter 5

Implementation

5.1 HTML5… .......................................................................................................... 10

5.2 PHP… ................................................................................................................ 10

5.3 SQL (Structured Query Language) .................................................................... 11

5.4 Code Snippets… ................................................................................................ 11

Chapter 6

Snapshots

6.1 The Login and Home Page................................................................................32

6.2 The Registration Page ....................................................................................... 33

6.3 The Cart Page .................................................................................................... 33

6.4 The Checkout Page ........................................................................................... 34

6.5 The Admin Login Page ..................................................................................... 34

6.6 The Admin Add Item Page ................................................................................ 35

6.6 The Admin View All Page ................................................................................ 35

6.8 Tables… ............................................................................................................ 36

Conclusion ..........................................................................................................................39

References ........................................................................................................................... 39

IV
LIST OF FIGURES

Fig No. Description Page No.


Fig 2.1 Components of a DBMS............................................................ 06

Fig 4.1 Schema Diagram….................................................................... 08

Fig 4.2 Entity Relational Diagram ......................................................... 09

Fig 5.4.1 Stored Procedure Page… ...........................................................30

Fig 6.6 The Triggered Action ................................................................ 31

Fig 6.1.1 The Home Page ......................................................................... 32

Fig 6.1.2 The Login Page. ......................................................................... 32

Fig 6.2 The Registration Page................................................................ 33

Fig 6.3 The Cart Page. ........................................................................... 33

Fig 6.4 The Checkout Page. ...................................................................34

Fig 6.5 The Admin Page. ...................................................................... 34

Fig 6.6 The Admin Add Item Page .........................................................35

Fig 6.7 The Admin View All Page ........................................................ 35

V
LIST OF TABLES

Table No. Description Page No.


Table 6-1 Categories Table. ..............................................................36

Table 6-2 Products Table. ................................................................ 36

Table 6-3 User Table........................................................................ 37

Table 6-4 Orders Table. ................................................................... 37

Table 6-5 Cart Table. ....................................................................... 38

VI
CHAPTER-1

INTRODUCTION

1.1 Introduction
Supermarket billing System is the Simple grocery ordering solution. It's a full-featured website and
cart system that bends over backwards to give you the flexibility you need to run your online store.
The basic concept of the application is to allow the customer to grocery virtually using the Internet
and allow customers to buy the grocery items of their desire from the store. The details of the items
are brought forward from the database for the customer view based on the selection through the
menu and the database of all the products are updated at the end of each transaction.

1.2 Problem statement


An Online Grocery Store represents a virtual process that includes online ordering. As an end-to-
end platform, digital Online Grocery Store must encompass the front end that consumers see , and
the back end that admins see through their servers and admin control panels and the middleware
that connects these nodes. Ultimately, an Online Grocery Store should facilitate all functional levels
of any normal grocery store people come across. However, the Online Grocery Store should bring
to people variety of products that many normal grocery stores do not consist of immediately.

1.3 Scope
Automation reduces the need for paper, which inevitably ends up taking up space that can be
occupied with technology. By using software that accelerates productivity up to 50%, online stores
or rather ecommerce stores can improve customer service since they will be able to resolve issues
at a faster pace. This also has led to few emerging forms of digital banking such as

• EAAS - Ecommerce store as a Service (allows for third party integration)


• EAAP - Ecommerce store as a Platform (for integrating core systems with software)
• Cloud-based Infrastructure (allows less reliance on IT staff)

1
CHAPTER-2

LITERATURE SURVEY

2.1 Traditional File System


In the early days of computing, data management and storage were a very new concept for
organizations. The traditional approach to data handling offered a lot of the convenience of the
manual approach to business processes (e.g., handwritten invoices & account statements, etc.) as
well as the benefits of storing data electronically.
The traditional approach usually consisted of custom-built data processes and computer information
systems tailored for a specific business function. An accounting department would have their own
information system tailored to their needs, where the sales department would have an entirely
separate system for their needs.
Initially, these separate systems were very simple to set up as they mostly mirrored the business
process that departments had been doing for years but allowed them to do things faster with less
work. However, once the systems were in use for so long, they became very difficult for individual
departments to manage and rely on their data because there was no reliable system in place to
enforce data standards or management.
Separate information systems for each business function also led to conflicts of interest within the
company. Departments felt a great deal of ownership for the data that they collected, processed, and
managed which caused many issues among company-wide collaboration and data sharing. This
separation of data also led to unnecessary redundancy and a high rate of unreliable and inconsistent
data.

2.2 Pros and Cons of the Traditional Approach


Pros:

 Simple
 Matched existing business processes and functions
 Companies were not as interested in funding complicated information systems
 Initially low-cost
 Early computing was not viewed as beneficial for large funding
 Systems were designed to be cheap in order to save on cost

Cons:
2
SUPERMARKET DATABASE SYSTEM LITERARY SURVEY

 Separated ownership
 Business functions had a high sense of data ownership
 Departments unwilling to share data for fear of minimizing their superiority
 Unmanaged redundancy
 Multiple instances of the same data appeared throughout various files, systems, and
Databases
 Information updated in one place was not replicated to the other locations
 Disk space was very expensive, and redundancy had a big impact on storage
 Data inconsistency
 Redundant data stored in various locations was usually never stored the same way
 Formatting was not centrally managed
 Lack of data sharing
 Same data stored in multiple locations
 Caused unnecessary doubling of efforts for processing and managing data
 High costs in the long run
 Hiring data processors for each department was very expensive, and each position was
typically working on the same thing just for a different area
 Doubling of work as well as excessive maintenance costs.

2.3 Downfall of Traditional Management System


Conceived in a relatively centralized era when software was deployed in static environments,
legacy database architectures fail to support an increasingly mobile world where applications are
accessed anytime, anywhere.
Today software users want consistent improvements in usability and expect SaaS vendors to deliver
new features and functionalities needed to achieve their business objectives. However, legacy
database technologies fall short. in serving the needs of todays distributed
and cloud environments for the following reasons:
• Inadequate failover capabilities
• Insufficient provisions during peak demands
• Latency issues
• Lack of high availability at all times
• Increasing operational costs
• Inability to meet the demands of global markets

V SEM, Dept. of CSE, 2022-23 3


SJBIT
SUPERMARKET DATABASE SYSTEM LITERARY SURVEY

For all of these reasons, traditional databases are. unable to deliver results in a rapidly growing
environment where the workload is geographically distributed across heterogeneous data centers.
Upgrading to a more distributed data model is costly and complicated and your DBAs cannot just
sit back and give up on this situation. Hence, due to these various reasons, the downfall of the
traditional system was inevitable.

2.4 Introduction to the Database Management System


A database management system (DBMS) refers to the technology for creating and managing
databases. Basically, a DBMS is a software tool to organize (create, retrieve, update and manage)
data in a database.
The main aim of a DBMS is to supply a way to store and retrieve database information that is both
convenient and efficient. By data, we mean known facts that can be recorded and that have
embedded meaning. Normally people use software such as DBASE IV or V, Microsoft ACCESS,
or EXCEL to store data in the form of database. A datum is a unit of Data. Meaningful data
combines to form.
Information. Hence, information is interpreted data- data provided with semantics.MS ACCESS is
one of the most common examples of database management software.
Database systems are meant to handle large collection of information. Management of data involves
both defining structures for storage of information and providing
mechanisms that can do the manipulation of those stored information. Moreover, the database
system must ensure the safety of the information stored, despite system crash or attempts at
unauthorized access.

2.5 Indicative areas for the use of a DBMS


 Airlines: reservations, schedules etc.
 Telecom: calls made, customer details, network usage etc.
 Universities: registration, results, grades, etc.
 Sales: products, purchases, customers etc.
 Banking: all transactions etc.

V SEM, Dept. of CSE, 2022-23 4


SJBIT
SUPERMARKET DATABASE SYSTEM LITERARY SURVEY

2.6 Advantages of a DBMS


A Database Management System has many advantages over the traditional file system used in the
earlier days, such as:
 Data independence: Application programs should be as free or independent as possible
from details of data representation and storage. DBMS can supply an abstract view of the
data for insulating application code from such facts.
 Efficient data access: DBMS utilize a mixture of sophisticated concepts and techniques for
storing and retrieving data competently and this feature becomes important in cases where
the data is stored on external storage devices.
 Data integrity and Security: If data is accessed through the DBMS, the DBMS can enforce
integrity constraint on the data.
 Data administration: When several users share the data, integrating the administration of
data can offer major improvements. Experienced professionals understand the nature of the
data being managed and can be responsible for organizing the data representation to reduce
redundancy and make the data to retrieve efficiently.

2.7 Components of a DBMS

Fig 2.1 Components of a DBMS

• Users: Users may be of any kind, such as data base administrators, system developers or database
users.

V SEM, Dept. of CSE, 2022-23 5


SJBIT
SUPERMARKET DATABASE SYSTEM LITERARY SURVEY

• Database application: Database application may be Departmental, Personal, Organizational and


/or Internal.
• DBMS: Software that allows users to create and manipulate database access.
• Database: Collection of logical data as a single unit.

V SEM, Dept. of CSE, 2022-23 6


SJBIT
CHAPTER 7

SOFTWARE REQUIREMENTS SPECIFICATIONS

3.1 Hardware Requirements

 Processor: Intel Core 2 Duo or above

 RAM: 2GB or more

 Hard Disk: 80 GB or more

3.2 Software Requirements

Technologies Used:

 Front End: HTML5, CSS, PHP

 Connection/Controller: PHP

 Back-End Database: MySQL

 Text Editor: Sublime Text

 Server: WAMP/APACHE/XAMPP server

 Operating System: Windows 10/Linux/MacOS

 Database Support: MySQL 5

 Back-End: PHP 7.2.8

7
CHAPTER 8

SYSTEM DESIGN

4.1 Schema Diagram


The term schema refers to the organization of data as a blueprint of how the database is constructed
(divided into database tables in case of relational databases). The formal definition of a database
schema is a set of formulas (sentences) called integrity constraint is imposed on a database.
A relational schema shows references among fields in the database. When a primary key is
referenced in another table in the database, it is called a foreign key. This is denoted by an arrow
with the head pointing at the referenced key attribute.
A schema diagram helps organize values in the database. It also gives an idea of what order the
tables should be created in. the following diagram shows the schema for the database.

Fig 4.1 Schema Diagram for Supermarket Database System

8
SUPERMARKET DATABASE SYSTEM SYSTEM DESIGN

4.2 Entity Relation Diagram


An entity-relationship model is usually the result of systematic analysis to define and describe
what is important to process in an area of a business.
An E-R model does not define the business processes; it only presents a business data schema in a
graphical form. It is usually drawn in a graphical form as boxes (entities) that are connected by
lines (relationships) which express the associations and dependencies between entities.
Entities maybe characterized not only by relationships, but also by additional properties
(attributes), which include identifiers called primary keys. Diagrams created to represent attributes
as well as entities and relationships may be called entity-attribute-relationship diagrams rather
than entity-relationship diagrams.

Fig 4.2 ER Diagram for Supermarket Database System

V SEM, Dept. of CSE, SJBIT 2022 – 23 9


CHAPTER 5

IMPLEMENTATION
5.1 HTML 5
HTML5 is a mark up language used for structuring and presenting content on the World Wide
Web. It is the fifth and current major version of the HTML standard.
It was published in October 2014 by the World Wide Web Consortium (W3C) to improve the
language with support for the latest multimedia, while keeping it both easily readable by humans
and consistently understood by computers and devices such as web browsers, parsers, etc.HTML5
is intended to subsume not only HTML 4, but also XHTML 1 and DOM Level 2 HTML.
HTML5 includes detailed processing models to encourage more interoperable implementations; it
extends, improves and rationalizes the mark up available for documents, and introduces mark up
and application programming interfaces (APIs) for complex web applications. Many new syntactic
features are included. To natively include and handle multimedia and graphical content, the new
<video>, <audio> and <canvas> elements were added, and support for scalable vector graphics
(SVG) content and MathML for mathematical formulas. To enrich the semantic content of
documents, new page structure elements such as<main>, <section>, <article>, <header>, <footer>,
<aside>, <nav> and <figure>, are added. New attributes are introduced, some elements and
attributes have been removed, and others such as <a>, <cite> and<menu> have been changed,
redefined or standardized.
The APIs and Document Object Model (DOM) are now fundamental parts of the HTML5
specification and HTML5 also better defines the processing for, any invalid documents.

5.2 PHP
PHP is a servlet-side scripting language designed primarily for web development but also used as a
general-purpose programming language. Originally created by Rasmus Lerdorf in I994, the PHP
reference implementation is now produced by The PHP Development Team. PHP originally stood
for Personal Home Page, but it now stands for the recursive acronym PHP: Hypertext Pre-processor.
PHP code may be embedded into HTML or HTML5 markup, or it can be used in combination with
various web template systems, web content management systems and web frameworks. PHP code
is usually processed by a PHP interpreter implemented as a module in the web server or as a
Common Gateway interface (CGI) executable. PHP code may also be executed with a command-
line interface (CLI) and can be used to implement standalone graphical applications.

10
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP
License. PHP has been widely ported and can be deployed on most web servers on almost every
operating system and platform, free of charge.
The PHP language evolved without a written formal specification or standard until 2014, leaving
the canonical PHP interpreter as a de facto standard. Since 2014 work has gone on to create a formal
PHP specification. PHP is a scripting language that helps people make web pages more interactive
by allowing them to do more things.
A website programmed with PHP can have pages that are password protected. A website with no
programming cannot do this without other complex things. Standard PHP file extensions are: php,
php3or, HTML, but a web server can be set up to use any extension.

5.3 SQL (Structured Query Language)


SQL (Structured Query Language) is a domain-specific language used in programming and
designed for managing data held in a relational database Management system (RDBMS), or for
stream processing in a relational data stream management system (RDSMS). In comparison to older
read/write APIs like [SAM or VSAM, SQL offers two main advantages: first, it introduced the
concept of accessing many records with one single command; and second, it eliminates the need to
specify how to reach a record, e.g., with or without an index.
Originally based upon relational algebra and tuple relational calculus, SQL consists of a data
definition language, data manipulation language, and data control language. Although SQL is often
described as, and to a great extent is, a declarative language (4GL), it also includes procedural
elements.
SQL became a standard of the American National Standards Institute (ANSI) in 1986 and of the
International Organization for Standardization (ISO) in 1987. Since then, the standard has been
revCSEd to include a larger set of features. Despite the existence of such standards, most SQL
code is not completely portable among different data base systems without adjustments.

5.4 Code Snippets

5.4.1 Config – To establish connection


This is a code snippet to show how PHP is used to connect to the local MySQL database using the
localhost server.

V SEM, Dept. of CSE, 2022 – 23 11


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<?php $servername = "localhost";

$username = "root";

$password = "";

$db = "SUPERMARKET"

$con = mysqli_connect($servername, $username, $password,$db);

if (!$con) {

die("Connection failed: " . mysqli_connect_error());

} ?>

5.4.2 The Login Page


<?php

include "db.php";

session_start();

#Login script is begin here

#If user given credential matches successfully with the data available in database then we will echo
string login_success

#login_success string will go back to called Anonymous funtion $("#login").click()

if(isset($_POST["email"]) && isset($_POST["password"])){

$email = mysqli_real_escape_string($con,$_POST["email"]);

$password = md5($_POST["password"]);

$sql = "SELECT * FROM user_info WHERE email = '$email' AND

password = '$password'";

$run_query = mysqli_query($con,$sql);

$count = mysqli_num_rows($run_query);

//if user record is available in database then $count will be equal to 1 if($count == 1){

$row = mysqli_fetch_array($run_query);

$_SESSION["uid"] = $row["user_id"];
V SEM, Dept. of CSE, 2022 – 23 12
SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

$_SESSION["name"] = $row["first_name"];

$ip_add = getenv("REMOTE_ADDR");

if (isset($_COOKIE["product_list"])) {

$p_list = stripcslashes($_COOKIE["product_list"]);

$product_list = json_decode($p_list,true);

for ($i=0; $i < count($product_list); $i++) {

//After getting user id from database here we are checking user cart item if there is already product
is listed or not

$verify_cart = "SELECT id FROM cart WHERE user_id = $_SESSION[uid] AND

p_id = ".$product_list[$i];

$result = mysqli_query($con,$verify_cart);

if(mysqli_num_rows($result) < 1){

//if user is adding first time product into cart we will update user_id into database table with valid
id

$update_cart = "UPDATE cart SET user_id = '$_SESSION[uid]' WHERE ip_add = '$ip_add' AND
user_id = -1";

mysqli_query($con,$update_cart);

}else{

//if already that product is available into database table we will delete that record

$delete_existing_product = "DELETE FROM cart WHERE user_id = -

1 AND ip_add = '$ip_add' AND p_id = ".$product_list[$i];

mysqli_query($con,$delete_existing_product);

//here we are destroying user cookie

setcookie("product_list","",strtotime("-1 day"),"/");

//if user is logging from after cart page we will send cart_login echo "cart_login";

exit();

}
V SEM, Dept. of CSE, 2022 – 23 13
SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

//if user is login from page we will send login_success echo "login_success";

exit();

}else{

echo "<span style='color:red;'>Please register before login..!</span>";

exit();

?>

?>

<!DOCTYPE html>

<html>

<body>

<head>

</head>

<meta charset="UTF-8">

<title>SUPERMARKET</title>

<link rel="stylesheet" href="css/bootstrap.min.css"/>

<script src="js/jquery2.js"></script>

<script src="js/bootstrap.min.js"></script>

<script src="main.js"></script>

<link rel="stylesheet" type="text/css" href="style.css">

<div class="wait overlay">

<div class="loader"></div>

</div>

<div class="navbar navbar-inverse navbar-fixed-top">

<div class="container-fluid">

V SEM, Dept. of CSE, 2022 – 23 14


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<div class="navbar-header">

<a href="#" class="navbar-

brand">SUPERMARKET</a>

</div>

<ul class="nav navbar-nav">

<li><a href="index.php"><span

class="glyphicon glyphicon-home"></span>Home</a></li>

<li><a href="index.php"><span class="glyphicon glyphicon-modal-


window"></span>Product</a></li>

</ul>

</div>

</div>

<p><br/></p>

<p><br/></p>

<p><br/></p>

<div class="container-fluid">

<div class="row">

<div class="col-md-2"></div>

<div class="col-md-8" id="signup_msg">

<!--Alert from signup form-->

</div>

<div class="col-md-2"></div>

</div>

<div class="row">

<div class="col-md-4"></div>

<div class="col-md-4">

<div class="panel panel-primary">

<div class="panel-heading">Customer Login Form</div>

V SEM, Dept. of CSE, 2022 – 23 15


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<div class="panel-body">

<!--User Login Form-->

<form onsubmit="return false" id="login">

<label for="email">Email</label>

<input type="email" class="form-control" name="email" id="email" required/>

<label for="email">Password</label><input type="password" class="form-control"


name="password" id="password" required/><p><br/></p>

<a href="#" style="color:#333; list-style:none;">Forgotten Password</a><input type="submit"


class="btn btn-success" style="float:right;" Value="Login">

<div><a href="customer_registration.php?register=1">Create a new account?</a></div>

</form></div>

<div class="panel-footer"><div id="e_msg"></div></div>

</div></div>

<div class="col-md-4"></div>

</div>

</body>

</html>

5.4.3 Registration Page


<?php session_start(); include "db.php";

if (isset($_POST["f_name"])) {

$f_name = $_POST["f_name"];

$l_name = $_POST["l_name"];

$email = $_POST['email'];

$password = $_POST['password'];

$repassword = $_POST['repassword'];

z]{2,4})$/";

$mobile = $_POST['mobile'];

V SEM, Dept. of CSE, 2022 – 23 16


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

$address1 = $_POST['address1'];

$address2 = $_POST['address2'];

$name = "/^[a-zA-Z ]+$/";

$emailValidation = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-

$number = "/^[0-9]+$/";

if(empty($f_name) || empty($l_name) || empty($email) || empty($password) ||

empty($repassword) ||

empty($mobile) || empty($address1) || empty($address2)){

echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label

='close'>&times;</a><b>PLease Fill all fields..!</b>

</div>";

exit();

} else { if(!preg_match($name,$f_name)){ echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria- label='close'>&times;</a>

<b>this $f_name is not valid..!</b>

</div>";

exit();

} if(!preg_match($name,$l_name)){ echo "

<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria- label='close'>&times;</a>

<b>this $l_name is not valid..!</b>

</div>";

exit();

} if(!preg_match($emailValidation,$email)){ echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

<b>this $email is not valid..!</b>

V SEM, Dept. of CSE, 2022 – 23 17


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

</div>";exit();}

if(strlen($password) < 9 ){

echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

<b>Password is weak</b>

</div>";exit();}

if(strlen($repassword) < 9 ){

echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

<b>Password is weak</b></div>";exit();}

echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria- label='close'>&times;</a>

<b>password is not same</b></div>";}

if(!preg_match($number,$mobile)){echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

<b>Mobile number $mobile is not valid</b></div>";exit();}

if(!(strlen($mobile) == 10)){

echo "<div class='alert alert-warning'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

<b>Mobile number must be 10 digit</b></div>";exit();}

$sql = "SELECT user_id FROM user_info WHERE email =

'$email' LIMIT 1" ;

$check_query = mysqli_query($con,$sql);

$count_email = mysqli_num_rows($check_query);

if($count_email > 0){

echo "<div class='alert alert-danger'>

<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>

V SEM, Dept. of CSE, 2022 – 23 18


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<b>Email Address is already available Try Another email address</b></div>";exit();

} else {

$password = md5($password);

$sql = "INSERT INTO `user_info`

(`user_id`, `first_name`, `last_name`, `email`,

`password`, `mobile`, `address1`, `address2`) VALUES (NULL, '$f_name', '$l_name', '$email',

'$password', '$mobile', '$address1', '$address2')";

$run_query = mysqli_query($con,$sql);

$_SESSION["uid"] = mysqli_insert_id($con);

$_SESSION["name"] = $f_name;

$ip_add = getenv("REMOTE_ADDR");

$sql = "UPDATE cart SET user_id =

'$_SESSION[uid]' WHERE ip_add='$ip_add' AND user_id = -1";

if(mysqli_query($con,$sql)){

echo "register_success";

exit();}}}

}?>

5.4.4 The Cart System


<?php?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>SUPERMARKET</title>

<link rel="stylesheet" href="css/bootstrap.min.css"/>

<script src="js/jquery2.js"></script>

V SEM, Dept. of CSE, 2022 – 23 19


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<script src="js/bootstrap.min.js"></script>

<script src="main.js"></script>

<link rel="stylesheet" type="text/css" href="style.css"/>

<link rel="stylesheet" type="text/css" href="w3.css"/>

</head>

<body>

<div class="wait overlay">

<div class="loader"></div>

</div>

<div class="navbar navbar-inverse navbar-fixed-top">

<div class="container-fluid">

<div class="navbar-header">

<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-


target="#collapse" aria-expanded="false">

<span class="sr-only">navigation</span>

<span class="icon-bar"></span>

<span class="icon-bar"></span>

<span class="icon-bar"></span>

</button>

<a href="#" class="navbar-brand">SUPERMARKET</a>

</div>

<div class="collapse navbar-collapse" id="collapse">

<ul class="nav navbar-nav">

<li><a href="index.php"><span class="glyphicon glyphicon-home"></span>Home</a></li>

<li><a href="index.php"><span class="glyphicon glyphicon-modal-


window"></span>Product</a></li>

</ul>

</div>

V SEM, Dept. of CSE, 2022 – 23 20


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

</div>

</div>

<p><br/></p>

<p><br/></p>

<p><br/></p>

<div class="container-fluid">

<div class="row">

<div class="col-md-2"></div>

<div class="col-md-8" id="cart_msg">

<!--Cart Message-->

</div>

<div class="col-md-2"></div>

</div>

<div class="row">

<div class="col-md-2"></div>

<div class="col-md-8">

<div class="panel panel-primary">

<div class="panel-heading">Cart Checkout</div>

<div class="panel-body">

<div class="row">

<div class="col-md-2 col-xs-2"><b>Action</b></div>

<div class="col-md-2 col-xs-2"><b>Product Image</b></div>

<div class="col-md-2 col-xs-2"><b>Product Name</b></div>

<div class="col-md-2 col-xs-2"><b>Quantity</b></div>

<div class="col-md-2 col-xs-2"><b>Product Price</b></div>

<div class="col-md-2 col-xs-2"><b>Price in Rs.</b></div>

</div>

V SEM, Dept. of CSE, 2022 – 23 21


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<div id="cart_checkout"></div>

<!--div class="row">

<div class="col-md-2">

<div class="btn-group">

<a href="#" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>

<a href="" class="btn btn-primary"><span class="glyphicon glyphicon-ok-sign"></span></a>

</div>

</div>

<!--div class="col-md-2"><img src='product_images/imges.jpg'></div>

<div class="col-md-2">Product Name</div>

<div class="col-md-2"><input type='text' class='form-control' value='1' ></div>

<div class="col-md-2"><input type='text' class='form-control' value='5000' disabled></div>

<div class="col-md-2"><input type='text' class='form-control' value='5000' disabled></div>

</div> -->

<!--<div class="row">

<div class="col-md-8"></div>

<div class="col-md-4">

<b>Total Rs.500000</b>

</div-->

</div>

<a href="checkout.php"><button class="w3-btn w3-green">Checkout</button></a>

</div>

<div class="panel-footer"></div>

</div>

</div>

<div class="col-md-2"></div>

</div>

V SEM, Dept. of CSE, 2022 – 23 22


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

</body>

</html>

5.4.5 The Checkout Page


<?php

session_start();

include "db.php";

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>SUPERMARKET</title>

<link rel="stylesheet" href="css/bootstrap.min.css"/>

<script src="js/jquery2.js"></script>

<script src="js/bootstrap.min.js"></script>

<script src="main.js"></script>

<style>

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

#search{width:80%;}

#search_btn{width:30%;float:right;margin-top:-32px;margin-right:10px;}

</style>

</head>

<body>

<div class="navbar navbar-inverse navbar-fixed-top">

<div class="container-fluid">

V SEM, Dept. of CSE, 2022 – 23 23


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<div class="navbar-header">

<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-


target="#collapse" aria-expanded="false">

<span class="sr-only"> navigation toggle</span>

<span class="icon-bar"></span>

<span class="icon-bar"></span>

<span class="icon-bar"></span>

</button>

<a href="#" class="navbar-brand">SUPERMARKET</a>

</div>

<div class="collapse navbar-collapse" id="collapse">

<ul class="nav navbar-nav">

<li><a href="index.php"><span class="glyphicon glyphicon-home"></span>Home</a></li>

<li><a href="index.php"><span class="glyphicon glyphicon-modal-


window"></span>Product</a></li>

<li style="width:300px;left:10px;top:10px;">

<form action="search.php" method="POST">

<input type="text" class="form-control" id="search" name="search"></li>

<li style="top:10px;left:20px;"><button class="btn btn-primary"


type='submit'>Search</button></li>

</form>

</ul>

<ul class="nav navbar-nav navbar-right">

<li><a href="#" id="cart_container" class="dropdown-toggle" data-toggle="dropdown"><span


class="glyphicon glyphicon-shopping-cart"></span>Cart<span class="badge">0</span></a>

<div class="dropdown-menu" style="width:400px;">

<div class="panel panel-success">

<div class="panel-heading">

<div class="row">

V SEM, Dept. of CSE, 2022 – 23 24


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<div class="col-md-3 col-xs-3">Sl.No</div>

<div class="col-md-3 col-xs-3">Product Image</div>

<div class="col-md-3 col-xs-3">Product Name</div>

<div class="col-md-3 col-xs-3">Price in Rs.</div>

</div>

</div>

<div class="panel-body">

<div id="cart_product">

</div>

</div>

<div class="panel-footer"></div>

</div>

</div>

</li>

<li><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon


glyphicon-user"></span><?php echo "Hi,".$_SESSION["name"]; ?></a>

<ul class="dropdown-menu">

<li><a href="cart.php" style="text-decoration:none; color:blue;"><span class="glyphicon


glyphicon-shopping-cart">Cart</a></li>

<li class="divider"></li>

<li><a href="customer_order.php" style="text-decoration:none; color:blue;">Orders</a></li>

<li class="divider"></li>

<li><a href="" style="text-decoration:none; color:blue;">Change Password</a></li>

<li class="divider"></li>

<li><a href="logout.php" style="text-decoration:none; color:blue;">Logout</a></li>

</ul>

</li>

</ul>

V SEM, Dept. of CSE, 2022 – 23 25


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

</div>

</div>

</div>

<p><br/></p>

<p><br/></p>

<p><br/></p>

<div class="container-fluid">

<div class="row">

<div class="col-md-1"></div>

<div class="col-md-2">

<div id="get_category">

</div>

<div id="get_brand">

</div>

</div>

<?php if (isset($_SESSION["uid"])) {

//When user is logged in this query will execute

$sql = "SELECT a.product_id,a.product_title,a.product_price,a.product_image,b.id,b.qty FROM


products a,cart b WHERE a.product_id=b.p_id AND b.user_id='$_SESSION[uid]'";

}else{

//When user is not logged in this query will execute

$sql = "SELECT a.product_id,a.product_title,a.product_price,a.product_image,b.id,b.qty FROM


products a,cart b WHERE a.product_id=b.p_id AND b.ip_add='$ip_add' AND b.user_id < 0";

$query = mysqli_query($con,$sql);

if (mysqli_num_rows($query) > 0) {

//display user cart item with "Ready to checkout" button if user is not login

echo "<form method='post' action='login_form.php'>";

V SEM, Dept. of CSE, 2022 – 23 26


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

$n=0;$total=0;

while ($row=mysqli_fetch_array($query)) {

$n++;

$product_id = $row["product_id"];

$product_title = $row["product_title"];

$product_price = $row["product_price"];

$product_image = $row["product_image"];

$cart_item_id = $row["id"];

$qty = $row["qty"];

$uid=$_SESSION['uid'];

$q="INSERT INTO orders(user_id,product_id,qty,p_status)


VALUES(".$uid.",".$product_id.",".$qty.",'Completed')";

$sql=mysqli_query($con,$q);

if($sql)

echo("Your order has been placed");

$q="DELETE FROM cart";

$sql=mysqli_query($con,$q);

?>

5.4.6 The Admin Page


<?php error_reporting(1); session_start();

$name=$_SESSION['eid'];

if($_REQUEST['log']=='out')

{ session_destroy(); header("location:index.php");

else if($name=="")
V SEM, Dept. of CSE, 2022 – 23 27
SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

header("location:index.php");

?>

<head>

<style>

a{text-decoration:none}

a:hover{background-color:#FFFFFF}

</style>

</head>

<body bgcolor="#FFFFFF" style="height:100%">

<div style="width:100%;float:left">

<div style="width:13%;float:left"><img src="usepics/9.jpg" width="182" height="166"/></div>

<div style="width:86.25%;height:27%;float:right;background-color:#99CC00">

<div style="width:30%;height:10%;float:right">

<!-- Start of Page Search -->

<h5>&nbsp;</h5>

<input type="text" name="t1" value="search" onfocus=" if(this.value=='search')

{this.value='';}" onBlur= "if(this.value=='')

{this.value='search';}

"/>

<input name="sub" type="submit" class="button" id="sub" value="Go" />

<h5>&nbsp;</h5>

<!--</form>-->

<!-- End of Page Search -->

</div>

<div style="width:50%;height:10%;float:right">

V SEM, Dept. of CSE, 2022 – 23 28


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

<br /><br /><br /><br/>

<a href="?con=hm"><font color="#660066" size="+2">Home</font></a>

&nbsp;&nbsp;&nbsp;&nbsp;

<a href="?log=out"><font color="#660066" size="+2">LogOut</font></a>

</div>

</div>

</div>

<div>

<div style="width:13.7%;height:100%;float:left;background-color:#99CC00">

<div align="center"><br />

<br />

<a href="?con=add"><font color="#660066" size="+2">Add

Item</font></a><br/>

<br />

<a href="?con=view"><font color="#660066" size="+2">View All</font>

</a><br/><br/>

</div>

</div>

<div style="width:86.2%;height:100%;float:right;background- image:url(usepics/p3.jpg)">

<?php switch($_REQUEST['con'])

case 'add':include("additem.php");

break;

case 'view':include("view.php");

break;

break;

break;

V SEM, Dept. of CSE, 2022 – 23 29


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

case 'ord':include("orders.php");

case 'fdbk':include("fdbk.php");

case 'hm':include("hm.php");

break;

</div>

</div>

</body>

</html>

if($_REQUEST['view'])

include("viewtable.php");

?>

5.4.7 Stored Procedure


The Stored procedure updates the Products Table with a product price. The new product price is
given by the admin.
The Procedure takes two parameters of IN type i) product_id ii) product_price

V SEM, Dept. of CSE, 2022 – 23 30


SJBIT
SUPERMARKET DATABASE SYSTEM IMPLEMENTATION

Fig 5.4.1 The Stored Procedure

5.4.8 Triggered Action


The Trigger will automatically calculate the total price wherever the item in the cart is updated. The
trigger takes the price of a single item from table products and multiplies it with the quantity and
update the total amount in table orders.

Fig 5.4.2 The Trigger

V SEM, Dept. of CSE, 2022 – 23 31


SJBIT
CHAPTER 6

SNAPSHOTS

6.1 The Login and Home Page


This is the users home page, all the users have access to this, this will inform the user about the
various categories of the products available. From this page the user can press the login or sign-up
button to login into the website or register if he is a new user.

Fig 6.1.1 Home Page of Supermarket Database System

Fig 6.1.2 Login Page of Supermarket Database System

32
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

6.2 Registration Page


If a user doesn’t have a account he can register himself as a customer by filling in username email
and a password in the given form.

Fig 6.2 Registration Page of Supermarket Database System

6.3 Cart Page


The Cart page contains the details of all the products the user wants to buy.

Fig 6.3 Cart Page of Supermarket Database System

V SEM, Dept. of CSE, 2022 – 23 33


SJBIT
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

6.4 Checkout Page


This page shows the list of all the purchases done by the user. This shows the amount.

Fig 6.4 Checkout Page of Supermarket Database System

6.5 The Admin Login


This page is used by the admin to login.

Fig 6.5 Admin Login Page of Supermarket Database System

V SEM, Dept. of CSE, 2022 – 23 34


SJBIT
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

6.6 The Admin Add Item Page


The admin after logging in can add new products which gets updated to the database.

Fig 6.6 Add Item Page of Supermarket Database System

6.7 The Admin View All Page


The Admin can select the category and view all the products in it.

Fig 6.7 View All Page of Supermarket Database System

V SEM, Dept. of CSE, 2022 – 23 35


SJBIT
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

6.8 TABLES

Table 6-1 Categories Table

Table 6-2 Products Table

V SEM, Dept. of CSE, 2022 – 23 36


SJBIT
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

Table 6-3 User Table

Table 6-4 Orders Table

V SEM, Dept. of CSE, 2022 – 23 37


SJBIT
SUPERMARKET DATABASE SYSTEM SNAPSHOTS

Table 6-5 Cart Table

V SEM, Dept. of CSE, 2022 – 23 38


SJBIT
CONCLUSION
With the theoretical inclination of our syllabus, it becomes very essential to take the utmost
advantage of any opportunity of gaining practical experience that comes along. The
construction of this mini project “Supermarket Management System” was one of these
opportunities. It gave us the requisite practical knowledge to supplement the already taught
theoretical concepts, thus making us more competent.
In conclusion, the Supermarket Management System has to make an appropriate effort to
stop the rising problem to all manual supermarket operations in order to enhance the
operation of such supermarkets. In this project, the software or system that can be used to
aid all supermarkets that are still operating manually have been successfully developed .
The software can be implemented in all types of supermarkets as mentioned in the first
chapter.

39
REFERENCES

Randy Connolly, Ricardo Hoar, "Fundamentals of Web Development”, 1stEdition, Pearson


Education India.

Database management systems, Ramakrishnan, and Gehrke, 3rd Edition, 2014, McGraw Hill.

The Bootstrap Website (for Design) – https://getbootstrap.com/

W3 Schools (HTML, CSS and PHP reference) – https://www.w3schools.com/

The MySQL Documentation – https://dev.mysql.com/doc/

PHP Official Documentation – https://php.net/docs.php/

Stack Overflow – https://stackoverflow.com/manual/en/reserved.variables.server.php

https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp

Stack Exchange – https://stackexchange.com/

https://www.w3schools.com/php/func_filesystem_link.asp

https://www.c-sharpcorner.com/UploadFile/63f5c2/triggers-in-sql-server/#:~:text=A%20SQL
%20trigger%20is%20a%20database%20object%20which%20fires%20when,insert%20in%20
a%20database%20table.

Wikipedia – https://www.wikipedia.org/triggers-database.

https://en.wikipedia.org/wiki/Database_trigger#:~:text=SQL%20allows%20triggers%20to%2
0fire,TABLE%20as%20the%20triggered%20action.

40

You might also like