Online Food Ordering System Implementation
Chapter 4
Implementation
4.1 Component Modules
Module 1: Login Window
The Login Window has two buttons, which will redirect to the required pages.
They are:
1. Login
2. Signup
[Link]:
Consists of definition of login page objects.
Contains links to different redirect to different pages.
Contains html code for the user interface used in login page.
Module 2: Home Page Window
This window consists of the home page, which displays all the categories of food
available and also the best sellers. Information about the website is accessed by clicking on
the about us button , the contact information can be viewed by clicking on contact us button
and logout button is clicked to end session.
[Link],[Link],[Link],[Link],[Link],Conatctus.
php, [Link], [Link]
Contains form based user interface for user home page
Contains member functions defined in php code.
The member functions used are:
Session_start (): This function is used to start a session and store session
variables.
Mysqli_connect (): This function is used to connect to the database
server, it takes 4 inputs ‘hostname’,’username’,’password’,’dbname’.
Isset (): This checks if the variable contains a value or not.
Mysqli_query (): this method is used to execute a query, it takes two
parameters ‘query’ and ‘connection’.
Mysqli_fetch_array(): this method is used to fetch the result set of the
executed query.
Dept. of ISE, SJBIT 2017-18 P a g e | 14
Online Food Ordering System Implementation
Contains buttons definition and functions.
Contains input slots definitions.
Module 3: Menu window
[Link]:
Contains html code for the button based interface.
Consists of header with links to the respective food categories and add to cart
buttons.
Contains the php code to select the items from the database and add to cart.
Consists of POST and SESSION variables to get the input from the form and
from the previous pages respectively.
Consists of member functions defined in php.
[Link]:
Contains html code for the button based interface.
Consists of header with links to the respective food categories and add to cart
buttons.
Contains the php code to select the items from the database and add to cart.
Consists of POST and SESSION variables to get the input from the form and
from the previous pages respectively.
Consists of member functions defined in php.
[Link]:
Contains html code for the button based interface.
Consists of header with links to the respective food categories and add to cart
buttons.
Contains the php code to select the items from the database and add to cart.
Consists of POST and SESSION variables to get the input from the form and
from the previous pages respectively.
Consists of member functions defined in php.
[Link]:
Contains html code for the button based interface.
Consists of header with links to the respective food categories and add to cart
buttons.
Contains the php code to select the items from the database and add to cart.
Dept. of ISE, SJBIT 2017-18 P a g e | 15
Online Food Ordering System Implementation
Consists of POST and SESSION variables to get the input from the form and
from the previous pages respectively.
Consists of member functions defined in php.
Module 4: MyAccount window
[Link]:
Contains html code for the buttons used in the interface.
Consists of member functions defined in php.
It allows the user to create their own profile and make changes.
[Link]
Contains html code for the buttons used in the interface.
Consists of member functions defined in php.
Action for the “save” button is directed here.
It contains a form which takes the input from the user to create the profile.
[Link]
Contains html code to view the details provided by the user.
Consists of member functions defined in php.
Only the required contents from the database are displayed.
Module 5: Cart window
[Link]:
Contains html code for the buttons used in the interface.
Consists of member functions defined in php.
It allows the user to view the selected food items and place the order.
[Link]:
Contains html code for the buttons used in the interface.
Consists of member functions defined in php.
It is a form based interface where the user has to enter the necessary details to
place the order.
[Link]:
Contains html code for the buttons used in the interface.
It is a radio button interface which allows the user to select the payment mode
Dept. of ISE, SJBIT 2017-18 P a g e | 16
Online Food Ordering System Implementation
4.2 Connection to database:
The database is connected to the front end html using php, the code for database
connection is shown below.
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "login";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
4.3 Table Creation:
Table 1: User
The User table consists of the main details of the user; it is shown in the diagram below,
User:
id First last uid pwd
id refers to the unique id of the user.
first refers to the first name of the user.
last refers to the last name of the user.
pwd refers to secret phrase known only to the user.
uid refers to the user name.
The table creation code is shown below:
CREATE TABLE `user` (
`id` varchar(10) AUTO_INCREMENT PRIMARY KEY,
`first` varchar(10) NOT NULL,
`last` varchar(10) DEFAULT NULL,
Dept. of ISE, SJBIT 2017-18 P a g e | 17
Online Food Ordering System Implementation
`uid` varchar(30) NOT NULL,
`pwd` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Fig 4.3.1 User Table
Table 2: Menu
The menu table consists of the food items available.
The table is shown below
Menu:
mid Item Descript amt
mid refers to the unique id of the user.
item refers to the food item.
descrip refers to the description of the item.
amt refers to the price of the item
The table creation code is shown below:
CREATE TABLE `menu` (
`mid` int(11) AUTO_INCREMENT PRIMARY KEY,
`item` varchar(20) NOT NULL,
`descrip` varchar(10) DEFAULT NULL,
`amt` int(5) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dept. of ISE, SJBIT 2017-18 P a g e | 18
Online Food Ordering System Implementation
Fig 4.3.2 Menu Table
Table 3: Useracc
Useracc table refers to the details of the user.
The table is shown below:
Useracc:
uid id Email Address phno
uid refers to the unique id of the user.
id is a foreign key which refers to the user.
email refers to the email
address refers to the address of the user
phno refers to the phone number
The table creation code is shown below:
CREATE TABLE `useracc` (
`mid’ int(10) AUTO_INCREMENT PRIMARY KEY,
`id` int(10) REFERENCE user(id),
‘email’ varchar(50) NOT NULL
‘address’ varchar(100) NOT NULL
‘phno’ int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dept. of ISE, SJBIT 2017-18 P a g e | 19
Online Food Ordering System Implementation
Fig 4.3.3 Useracc Table
Table 4: CHECKOUT
checkout table consists of the details required for delivery.
It is shown in the diagram below
checkout:
Chid uid Address Pincode phno
chid refers to the unique id of the user
uid is a foreign key which refers to the user.
Address refers to the address.
pincode refers to the pincode .
phno refers to the phone number of the user.
The table creation code is shown below:
CREATE TABLE `checkout` (
`chid` int(10) AUTO_INCREMENT PRIMARY KEY,
`uid` int(10) REFERENCE user(id),
`address` varchar(100) NOT NULL,
`pincode` int(6) NOT NULL,
`phno` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dept. of ISE, SJBIT 2017-18 P a g e | 20
Online Food Ordering System Implementation
Fig 4.3.4 Checkout Table
Table 5: ORDER
Order table refers to the details of the order placed.
The diagram is shown below
Order:
Oid uid id Status date time
oid refers is to the unique id of the user
uid is a foreign key which refers to the user.
id is a foreign key which refers to the user.
status refers to the status of the order
date refers to the date of order placement
time refers to the time of the order placement
The table creation code is shown below:
CREATE TABLE `order` (
`oid` int(10) AUTO_INCREMENT PRIMARY KEY,
`uid` int(10) REFERENCES useracc(uid),
`id` int(10) REFERENCES user(id),
`uid` varchar(10) NOT NULL,
`status` varchar(100) NOT NULL,
`date` date NOT NULL,
`time` timestamp NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dept. of ISE, SJBIT 2017-18 P a g e | 21
Online Food Ordering System Implementation
Fig 4.3.5 Order Table
Table 6: Trigger_time
Order table refers to the details when user signs.
The diagram is shown below
Trigger_time:
id exec_time
id is a foreign key which refers to the user.
exec_time refers to the time when user signs in.
The table creation code is shown below:
CREATE TABLE `checkout` (
`id` int(10) REFERENCE user(id) PRIMARY KEY,
`Exec_time` timestamp NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Fig 4.3.6 Trigger_time Table
Stored procedure:
A procedure (often called a stored procedure) is a subroutine like a subprogram
in a regular computing language, stored in database. There are many useful applications
of SQL procedures within a database or database application architecture. SQL
Dept. of ISE, SJBIT 2017-18 P a g e | 22
Online Food Ordering System Implementation
procedures can be used to create simple scripts for quickly querying transforming,
updating data, generating basic reports, improve application performance, modularizing
applications, and improve overall database design, and database security.
The procedure used in this project is called disp1, which returns the all the
bookings done by all the users.
Code:
DELIMITER $$
CREATE DEFINER=`'root' `@` 'localhost'` PROCEDURE `disp1`()
NO SQL
BEGIN
SELECT * FROM order;
END$$
DELIMITER ;
Trigger:
Triggers are stored programs, which are automatically executed or fired when
some event occurs. Triggers are written to be executed in response to any of the
following events. A database manipulation (DML) statement (DELETE, INSERT, or
UPDATE). A database definition (DDL) statement (CREATE, ALTER, or DROP).
The trigger named time1 used in this project enters the time at which a user made
a new booking.
The code of trigger is give below
Code :
CREATE TRIGGER `trigger_time` BEFORE INSERT ON `user`
FOR EACH ROW INSERT INTO TRIGGER_TIME VALUES( now());
Dept. of ISE, SJBIT 2017-18 P a g e | 23