Food and Diet
Food and Diet
1. INTRODUCTION
In the modern era, computers have made everything under one roof and have
knit the world together. Even the complicated and time consuming works are made
nothing by the computers. Because of the technological IT revolution computers has
been made as the core element in every place. Computerization has become an essential
one, for the people who prefer speedy and ease of access. Human beings are liable to
make mistakes and the output usually depends upon the efficiency of the persons
involved. But computers could usually generate error output and highly efficient which
varies depending on the person operating.
Food and Diet Analyzer helps the users to find their right diet chart based on
their Body Mass Index, weight and their style of life. Along with that ,the diabetic
patients can find their food chart based on their blood sugar range.
The project entitled “Food and Diet Analyzer” is developed with an aim of
providing right diet chart for the normal users and also specifically for the diabetic
patients. The food chart is generated by getting user’s style of life, weight, etc. The users
can also create their own profile by using their personal information. The project is
developed using
1
Diabetic food chart
Security
All the above modules are designed to meet the requirements of a user. The interface
is developed with a rich interface and user-friendly Environment.
2
2. SYSTEM CONFIGURATION
3
2.3. SOFTWARE DECRIPTION
The PHP syntax is very similar to Perl and C. PHP is often used together with
Apache (web server) on various operating systems. It also supports ISAPI and can be
used with Microsoft's IIS on Windows.
A PHP file may contain text, HTML tags and scripts. Scripts in a PHP file are
executed on the server. Of course general scripting or programming languages like Perl,
Python, etc. have also platform independence, and are open source.
PHP was designed to work on the web, and in this ambit it excels connecting and
querying a database is a simple task that can be handled in 2 or 3 lines of code. The PHP
scripting engine is well optimized for the response times needed on web applications it
can even be part of the web server itself improving the throughput even more.
The PHP language features the usual complement of control structures, operators,
variable types, function declarations and class/object declarations that we have been
accustomed to expect from any compiled or interpreted language, and yet it also has
4
features of its own. For example, in C you employ pointers, in other scripting languages
this can be cumbersome or even not possible, but in PHP this is just one use of variable
variables.
PHP comes with a myriad of options, both to build the distribution and also to configure
an installation. PHP supports several APIs and interfaces to other programming tools .The
sheer number of these tools is daunting, not to speak of the configuration possibilities for
each of these.
PHP was originally created by RasmusLerdorf in 1995 and has been in continuous
development ever since. The main implementation of PHP is now produced by The PHP
Group and serves as the de facto standard for PHP as there is no formal specification is
free software released under the PHP License, which is incompatible with the General
Public License (GPL) because restrictions exist regarding the use of the term PHP.
5
Usage
PHP primarily acts as a filter, taking input from a file or stream containing text
and/or PHP instructions and outputs another stream of data; most commonly the output
will be HTML. Since PHP 4, the PHP parser compiles input to produce byte code for
processing by the Zend Engine, giving improved performance over its interpreter
predecessor.
Originally designed to create dynamic web pages, PHP now focuses mainly on
server-side scripting, and it is similar to other server-side scripting languages that provide
dynamic content from a web server to a client, such as Microsoft's Active Server Pages,
Sun Microsystems' JavaServerPages, and modern. PHP has also attracted the
development of many frameworks that provide building blocks and a design structure to
promote rapid application development (RAD). Some of these include CakePHP,
Symphony, CodeIgniter, and Zend Framework, offering features similar to other web
application frameworks.
The LAMP architecture has become popular in the web industry as a way of
deploying web applications. PHP is commonly used as the P in this bundle alongside
Linux, Apache and MySQL, although the P may also refer to Python or Perl or some
combination of the three.
6
Hyper Text Mark-up Language (HTML)
HTML stands for Hyper Text Mark-up Language. Hypertext is ordinary text that
has been dressed up with extra features, such as formatting, images, multimedia, and
links to other documents. Mark up is the process of taking ordinary text and adding extra
symbols. Language is actually a key point to remember about HTML. HTML is a
universal language for classifying the function of different sections of a document. It is
neither a page-layout language nor a printing language. This allows documents to be
displayed on many different kinds of platforms. HTML is flexible to work on the website
with their variety of commands.
MY-SQL 4.0
7
Yet another feature of MySQL is its portability—it has been ported to almost every
platform. This means that you don't have to change your main platform to take advantage
of MySQL. And if you do want to switch, there is probably a MySQL port for your new
platform.
MySQL also has many different application programming interfaces (APIs). They
include APIs for Perl, TCL, Python, C/C++, Java (JDBC), and ODBC. So no matter what
your company's expertise is, MySQL has a way for you to access it.
MySQL is also very cheap. For an unlicensed, full version of MySQL, the cost is
nothing. To license your copy will currently cost you $200. This is an incredible deal,
considering what you are getting for your money.
Database systems that provide half the features that MySQL has can cost tens of
thousands of dollars. MySQL can do what they do better and for less.
MySQL is a relational database. It uses tables and columns to hold data that can
be related by keys. It is well suited for this role. It is also very well suited for various
architectures. It can be used in a strictly client/server architecture or
as a standalone database.
MySQL has various data types that support different functions. A data typeis the
type of data a column will store. There can be many different data types inside a table,
but each column will store its own specific type of information. You can think of a data
type as a kind of definition for a column.
8
basically three groups of data formats. The first is obviously numeric. Numeric data is
data that is a positive or negative number such as 4 or -50.
It consists of everything that doesn't quite fit into either of the other two
categories. Some, like dates and times, could be alphanumeric but are stored like
numbers. As well as data types, MySQL also provides column modifiers. These modifiers
further help define a column's attributes.
MySQL runs on many platforms, and binaries are available for most of them.
Binaries are the result of compiling the source code. This is by far the easiest way of
acquiring MySQL. The alternative is downloading the source code for your platform and
then compiling it.
MySQL has many utilities to import as well as export data. It shares some of the common
options, but this utility does a little more. It takes the entire database and dumps it into a
single text file.
This file contains all the SQL commands needed to recreate your database. It
takes the schema and converts it to the proper DDL syntax (CREATE statements), and it
takes all the data and creates INSERT statements out of them. This utility reverse
engineers your database.
9
3. SYSTEM ANALYSIS
3.1 EXISTING SYSTEM
The existing system is available only for displaying a common diet chart and also
BMI calculation is done manually using formula. The system has the objective of
providing specific diet chart based on individual user’s weight and life style and also the
diet chart for the diabetic patients based on their blood sugar level.
.
Drawbacks of existing system
The proposed system is developed after a detailed study about the requirements
requested by the user. Proposed system is a computerized one, where all the limitations of
manual system are compensated. The proposed system shall have the following features.
10
THE ADVANTAGES OF THE PROPOSED SYSTEM
Less time consumption and manpower
Fast and economical
Accurate calculation
More interactive screens
Large database capacity
Easy report generating
11
4. SYSTEM DESIGN
4.1 ER DIAGRAM
12
4.2 DATAFLOW DIAGRAM
LEVEL-0
LEVEL-1
13
4.3 DATABASE DESIGN
PRIMARY KEY : NR
DATA
FIELD NAME SIZE DESCRIPTION
TYPE
NR TEXT 10 FOOD NUMBER
NAME NUMBER 20 NAME OF THE FOOD
DESCRIPTION ABOUT THE
DESCRIPTION TEXT 30
FOOD
CATEGORY TEXT 30 CATEGORY OF THE FOOF ITEM
SERVING TEXT 10 ENERGY SERVING
TOTAL CALORIES OF THE
CALORIES 10
INT FOOD
PRIMARY KEY : NR
DATA
FIELD NAME SIZE DESCRIPTION
TYPE
FOOD NR INT 10 FOOD NUMBER
NUTRI NAME VARCHAR 25 NUTRITION NAME
VALUE VARCHAR 10 NUTRITIONAL VALUE
PRIMARY KEY : NR
DATA
FIELD NAME SIZE DESCRIPTION
TYPE
NR INT 10 PLAN NUMBER
USER_NR INT 10 USER NUMBER
AGE INT 5 USER AGE
GOAL VARCHAR 50 USER GOAL
HEIGHT INT 10 HEIGHT OF TE USER
CURRENT WEIGHT INT 5 USER’S CURRENT WEIGHT
GOAL WEIGHT INT 5 USER’S GOAL WEIGHT
LIFE STYLE VARCHAR 20 USER’S CURRENT LIFE STYLE
SUGGESTED LIFE SUGGESTED LIFE STYLE FOR THE
VARCHAR 20
STYLE USER
CALORIEPERDAY INT 10 TOTAL CALORIES PER DAY
CREATED DATE - DATE OF THE PROFILE CREATION
STATUS INT 10 STATUS OF THE USER
15
TABLE NAME : USERS
PRIMARY KEY : NR
DATA
FIELD NAME SIZE DESCRIPTION
TYPE
NR INT 10 USER NUMBER
USERNAME VARCHAR 50 USERNAME OF THE USER
PASS VARCHAR 30 PASSWORD OF THE USER
PASSMD VARCHAR 20 MODE OF PASSWORD
EMAIL VARCHAR 20 EMAIL OF THE USER
USERTYPE VARCHAR 10 TYPE OF USER
FNAME VARCHAR 50 FIRSTNAME
MNAME VARCHAR 20 MIDDLENAME
LNAME VARCHAR 20 LASTNAME
DOB DATE - DATE OF BIRTH
ADDRESS VARCHAR 100 ADDRESS OF THE USER
HEIGHT INT 10 HEIGHT OF THE USER
WEIGHT INT 3 WEIGHT OF THE USER
GENDER VARCHAR 8 USER’S GENDER
16
Inaccurate input data are the most common cause of errors in data processing.
Errors entered by data entry operators can be controlled by input design. Input design is
the process of converting user originated inputs to computer based format. In the DFD
phase, the expanded data flow diagram identifies logical data flows, data stores, sources
and destinations. It also specifies the master files and attendance files.
A source document should be logical and easy to understand. Each area should be
clearly identified and should specify as what the user should enter. The analyst must
decide the methods of inputting the data into the system. Input devices used in this
system are keyboard and mouse. The input design consists of specifications and
procedures for data preparation and entry.
The Multiple Document Interface (MDI) was designed to simplify the exchange
of information among documents, all under the same roof. With the main application, we
can maintain multiple open windows, but not multiple copies of the application. Data
exchange is easier when we can view and compare many documents simultaneously.
Food and Diet Analyzer is designed using the multiple document interface (MDI)
form which will include all other forms in it.
17
User goal entry
User can enter their current weight, current height and their style of life to create
their own plan and to get their diet chart along with life style suggestions.
18
4.5 OUTPUT DESIGN
Computer output is the most important and direct source of information to the
user. Efficient and intelligible output design will improve the system’s relationships with
the user and help in decision making. A major form of output factors such as
compatibility of the device with the system, response time requirements, expected print
quality and number of copies needed.
19
5. SYSTEM TESTING AND IMPLEMENTATION
SYSTEM TESTING
After each program passes its own test, its linkage to other programs is scrutinized
with a program integration test. This ensures that the entire system works together as
intended.
Before the implementation phase, the designed system should be tested with raw
data to ensure that all modules of the system work correctly and satisfactorily. If some
bug is found, it can be removed. There are four kinds of testing.
UNIT TESTING
Unit testing focuses the verification effort on the smallest unit of S/W design i.e.,
the module. The unit testing is always white-box oriented and the step can be conducted
in parallel for modules.
During unit test, testers can use the same project or projects as the developers, if
functional units organize the project, or separate projects have been created for functional
units. The project or projects can also be exported, so unit test can take place in a variety
of environments and on a variety of platforms.
‘Boundary Conditions’ are tested to ensure that the module operates properly at
boundaries established to limit or restrict processing. All ‘independent paths’ through the
20
control structures are exercised to ensure that all statements in a module have been
executed at least once. Finally, all ‘error-handling paths’ are tested.
In most applications, a driver is nothing more than a main program that accepts
test case data, passes such data to the module to be tested, and prints the relevant results.
The stubs serve to replace modules that are subordinates called by the modules to be
tested. A stub or a dummy stub or a dummy subprogram uses the subordinate modules
interface, may do minimal data manipulation, prints verification of entry, and returns. The
drivers and scrubs represent overhead i.e., both are S/W that must be written but that is
not delivered with the final S/W product. If the drivers and the stub are kept simple, then
the overhead is low.
The Unit Test is carried out in this project, and is found successful. The data is
flowing correctly to all part of the project.
SYSTEM IMPLEMENTATION
Implementation is the state in the project where the theoretical design is turned
into a working system. The most crucial stage is achieving a new successful system and
in confidence that the new system will work efficiently and effectively for the user.
21
The system can be implemented only after through testing is done and if it is
found to work to the specifications. It involves careful planning and investigation of the
current system and its constraints on implementation.
Two major tests of preparation for implementation are educating and training of
users and testing the system. The most difficult task in the system life cycle is the
successful implementation of the new system design. Implementation includes all those
activities that take place to convert from the old system to the new system. The new
system may be that a major implementation becomes necessary so that a reliable system
based on the requirements of the organization can be provided.
1. Training personal
2. Conversion procedure
3. Post implementation review
22
IMPLEMENTATION PROCEDURE
The Implementation phase can be described as the phase in which the game is
truly constructed, programmed and executed. This phase involves programming,
debugging, compiling and executing.
23
6. SCOPE FOR FUTURE ENHANCEMENTS
24
7. CONCLUSION
The system “Food and Diet Analyzer” deals with providing the right diet chart
for the users based on their height, weight, gender and their style of life. This Software is
more user friendly so that the user with basic knowledge about computer can easily
access with this software.
Another added feature is the diabetic food chart. The diabetic patients can access
this software to get the diet chart for their particular diabetic levels. Thus this software is
designed with the aim of creating diet awareness among the users and achieved the
outcome successfully.
25
BIBLIOGRAPHY
BOOKS REFERRED
WEBSITE REFERRED
1. www.w3schools.com
2. www.codeproject.com
3. www.sourcecode.com
4. www.wikipedia.com
26
5. www.onlineprojects.com
APPENDICES
A.SCREEN SHOTS
27
28
29
30
31
B.SAMPLE CODING
Connection
<?php
session_start();
localtime();
$hostname="localhost";
$user="root";
$password="";
$database="dbnutcal";
if (!($con_db=mysql_connect($hostname,$user,$password))){
die("Can't connect to database!");
}
else{
if(!( mysql_select_db("$database",$con_db))){
die("Can't connect to database!");
}
}
32
Check login
<?php
if($count==1){
$q = mysql_fetch_array($s);
$u = $q['UserType'];
if ($q == "admin") {
header("Location: admin/index.php");
}
}
}
else{
session_destroy();
header("Location: register.php");
}
Home
<?php
include 'conn.php';
include 'check_login.php';
$user = $_SESSION['user'];
$pass = $_SESSION['pass'];
$msg = 0;
if (isset($_POST['submit'])) {
$efname = $_POST['fname'];
$emname = $_POST['mname'];
$elname = $_POST['lname'];
$eaddress = $_POST['address'];
$egender = $_POST['gender'];
$edob = $_POST['dob'];
33
$eheight = $_POST['height'];
$eweight = $_POST['weight'];
if (mysql_error()) {
$msg = 1;
$message = mysql_error();
} else {
$msg = 2;
$message = "Your Personal Information had been updated.";
}
}
$dob = $r['DoB'];
$height = $r['Height'];
$weight = $r['Weight'];
?>
<!doctype html>
<meta charset="utf-8">
34
</head>
<body>
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-
target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img alt=""
src="images/logo.png"></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a class="active" href="index.php">Profile</a>
<li><a href="security.php">Account</a></li>
<li><a href="plans.php">Plans</a></li>
<li><a href="logout.php">Logout</a></li>
<li><a href="dia.php">diabetes</a></li>
</ul>
</div>
</div>
</div>
</header>
<!-- End Header -->
<!-- content
================================================== -->
<div id="content">
<div class="page-banner">
35
<div class="container">
<h2>Welcome <?php echo $r['FName']. " " .$r['LName']; ?></h2>
<ul class="page-tree">
<li><a href="#">Home</a></li>
</ul>
</div>
</div>
36
<div class="col-md-10">
<?php
?>
</p>
</div>
<div class="col-md-10">
<?php
echo $r['Address'];
?>
</p>
</div>
<div class="col-md-5">
<?php
?>
</p>
37
</div>
<div class="col-md-5">
<?php
$age = $birthdate->diff($today)->y;
echo $age;
?>
</p>
</div>
<div class="col-md-5">
<?php
echo $r['Gender'];
?>
</p>
</div>
<div class="col-md-5">
38
<p style="font-size: 16px; margin-left: 5%;">
<?php
if ($weight == "") {
} else {
?>
</p>
</div>
<div class="col-md-5">
<?php
if ($height == "") {
} else {
?>
</p>
</div>
</div>
39
<div><h1>BMI</h1>
<?php
$bmi = ($weight / ($height * $height)) * 703;
echo "<h3>".$bmi."</h3>";
}
else{
echo "No data Yet";
}
?>
</div>
</div>
</form>
</div>
</div>
<div class="tab-content">
<div class="leave-
comment">
<h3>Update Personal
Information</h3>
<form
class="comment-form" method="post">
<div
class="row">
<div
class="col-md-10">
40
<div class="col-md-10">
</div>
<div class="col-md-10">
</div>
<div class="col-md-5">
<option>Male</option>
<option>Female</option>
</select>
</div>
<div class="col-md-5">
41
<label style="float:left; width: 100%;">Date of Birth:</label>
</div>
<div class="col-md-5">
</div>
<div class="col-md-5">
</div>
<div class="col-md-10">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End content -->
42
<!-- footer
================================================== -->
<?php
include 'footer.html';
?>
<!-- End footer -->
</div>
<!-- End Container -->
<!--[if lt IE 9]>
<script
src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</body>
Logout
<?php
session_start();
session_destroy();
header("Location: index.php");
Register
<?php
include "conn.php";
include 'check.php';
$message = "";
$msg = 0;
if(isset($_POST['submit'])){
$uname = $_POST['user'];
43
$pword = md5($_POST['pass']);
$msg = 1;
if ($num == 1) {
$rec = mysql_fetch_array($q);
$type = $rec['UserType'];
$_SESSION['user'] = $uname;
$_SESSION['pass'] = $pword;
$_SESSION['type'] = $type;
if ($type == "admin") {
header("Location: admin/index.php");
} else {
header("Location: home.php");
}
} else {
session_destroy();
$msg = 1;
$message = "Username or Password is not valid.";
}
}
else if (isset($_POST['sign'])) {
$reg_user = $_POST['reg_username'];
$n = mysql_num_rows($q_user);
if ($n > 0) {
$msg = 1;
$message = "The username you provided is not available. Choose
another." . mysql_error();
} else {
$fname = $_POST['fname'];
$mname = $_POST['mname'];
$lname = $_POST['lname'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$height = $_POST['height'];
$weight = $_POST['weight'];
44
$address = $_POST['address'];
$reg_pass = $_POST['reg_pass'];
$md_pass = md5($reg_pass);
if (mysql_error()) {
$msg = 1;
$message = mysql_error();
} else {
$_SESSION['user'] = $reg_user;
$_SESSION['pass'] = $md_pass;
$_SESSION['type'] = "user";
header("Location: home.php");
}
}
}
?>
<!doctype html>
<html lang="en" class="no-js">
<head>
<title>Login/Register Here</title>
<meta charset="utf-8">
45
==================================================
-->
<header class="clearfix">
<!-- Static navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-
toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"
href="index.php"><img alt="" src="images/logo.png"></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a
href="index.php">Home</a></li>
<li><a href="about.html">About
Us</a></li>
<!-- <a href="#">Blog</a></li> -->
<li><a class="active"
href="register.php">Log-in/Register</a></li>
</ul>
</div>
</div>
</div>
</header>
<!-- End Header -->
<!-- content
================================================== -->
<div id="content">
46
</ul>
</div>
</div>
<div class="leave-comment">
<h3>Login</h3>
<?php
if ($msg == 1) {
?>
<div class="comment-form msg error"><?php echo
$message; ?></div>
<?php
}
?>
<form class="comment-form" method="post">
<div class="row">
<div class="col-md-10">
<input type="text" name="user" id="username"
placeholder="Username" style="width: 29%; float: left; margin-left: 20px;" required
autofocus/>
<input type="password"
name="pass" placeholder="Password" style="width: 29%; float: left; margin-left: 20px;"
required/>
<input type="submit"
name="submit" value="login" style="width: 15%; float: left; margin-left: 20px; height:
55px;"/>
</div>
</div>
</form>
</div>
<div class="leave-comment">
<h3>Register</h3>
<form class="comment-form" method="post">
<div class="row">
<div class="col-md-10">
<div class="col-md-10">
<label style="float:left;
width: 100%;">Name:</label>
<input type="text"
name="fname" placeholder="First Name" style="width: 30%; float: left; margin-left:
20px;" required/>
<input type="text"
name="mname" placeholder="Middle Name" style="width: 30%; float: left; margin-left:
20px;" required/>
<input type="text"
name="lname" placeholder="Family Name" style="width: 29%; float: left; margin-left:
20px;" required/>
47
</div>
<div class="col-md-5">
<label style="float:left;
width: 100%;">Date of Birth:</label>
<input type="text"
name="dob" placeholder="yyyy-mm-dd" style="width: 90%; float: left; margin-left:
20px;" required/>
</div>
<div class="col-md-5">
<label style="float:left;
width: 100%;">Gender:</label>
<select name="gender"
style="width: 87%; float: left; margin-left: 20px; margin-top: 0px;">
<option>Male</option>
<option>Female</option>
</select>
</div>
<div class="col-md-10">
</div>
<div class="col-md-10">
</div>
<div class="col-md-10">
<label style="float:left;
width: 100%;">Address:</label>
<input type="text"
name="address" placeholder="Address" style="width: 94%; float: left; margin-left:
20px;" required/>
</div>
<div class="col-md-10">
<label style="float:left;
width: 100%;">Desired Username:</label>
48
<input type="text" name="reg_username"
id="reg_username" placeholder="Username" style="width: 94%; float: left; margin-left:
20px;" required/>
</div>
<div class="col-md-10">
<label style="float:left;
width: 100%;">Desired Password:</label>
<input type="password"
name="reg_pass" id="reg_pass" placeholder="Password" style="width: 94%; float: left;
margin-left: 20px;" required/>
<input type="submit"
name="sign" value="sign up" style="width: 15%; height: 55px; margin-right: 3%;"/>
</div>
</div>
</div>
</form>
</div>
</div>
<?php
include 'footer.html';
?>
</body>
</html>
49