0% found this document useful (0 votes)
404 views49 pages

Food and Diet

......

Uploaded by

Muthu kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
404 views49 pages

Food and Diet

......

Uploaded by

Muthu kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 49

FOOD AND DIET ANALYZER

1. INTRODUCTION

1.1 PROJECT OVERVIEW

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

 PHP -Front End Tool


 SQL- Back end tool

The project is broadly divided into following modules


 Registration
 Profile
 Plans

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

2.1 SOFTWARE SPECIFICATION

Operating System : Windows XP/ Windows 10/ Windows 8.1

Language : PHP 5.0

Back end : mySQL

2.2 HARDWARE SPECIFICATION

Processor : Intel® Core™ Duo CPU E7400


CPU Clock Speed : 2.80GHZ
RAM : 2.00GB
Hard disk : 150 GB
Monitor : 17” VGA color monitor
Key board : 104 Keys or above
Mouse : Two Buttons Scrolling Mouse

3
2.3. SOFTWARE DECRIPTION

Overview of PHP 5.0

PHP (acronym for: PHP Hypertext Pre-processor), is a server-side embedded


scripting language. This means that it works within an HTML document to confer to it
the capacity of generating content on demand. You can convert your site into a web
application, not just a collection of static pages with information that may not get updated
quite so often, which may be alright for a "personal" web site.

PHP is the widely-used, free, and efficient alternative to competitors such as


Microsoft's ASP. PHP is perfectly suited for Web development and can be embedded
directly into the HTML code.

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.

Before we get involved in the detail of installing PHP, it would be worthwhile to


consider what we would expect to do with PHP in the near future. Depending on this we
need to include only those particular modules that are germane to the kind of stuff we
plan to do with the installation.

Hypertext Pre-processor (PHP) is a widely used, general-purpose scripting


language that was originally designed for web development to produce dynamic web
pages. For this purpose, PHP code is embedded into the HTML source document and
interpreted by a web server with a PHP processor module, which generates the web page
document. As a general-purpose programming language, PHP code is processed by an
interpreter application in command-line mode performing desired operating system
operations and producing program output on its standard output channel. It may also
function as a graphical application. PHP is available as a processor for most modern web
servers and as standalone interpreter on most operating systems and computing platforms.

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 is a general-purpose scripting language that is especially suited to server-side


web development where PHP generally runs on a web server. Any PHP code in a
requested file is executed by the PHP runtime, usually to create dynamic web page
content. It can also be used for command-line scripting and client-side GUI applications.
PHP can be deployed on most web servers, many operating systems and platforms, and
can be used with many relational database management systems. It is available free of
charge, and the PHP Group provides the complete source code for users to build,
customize and extend for their own use.

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.

As a formatting language, HTML utilizes SGML (Standard General Mark-up


Language) and Document Type Declarations (DTD). SGML document has three main
parts. The first part defines the character set to be used and tells which character i that set
distinguishes text for mark-up tags. Mark-up tags specify how the viewer application or
browser should present the text to the user.

2.4 OVERVIEW OF BACK-END

MY-SQL 4.0

MySQL is a full-featured relational database management system. It is very stable


and has proven itself over time. MySQL has been in production for over 10 years.
MySQL is a multithreaded server. Multithreaded means that every time someone
establishes a connection with the server, the server program creates a thread or process to
handle that client's requests. This makes for an extremely fast server. In effect, every
client who connects to a MySQL server gets his or her own thread.

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.

The MySQL Supported Type

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.

A column defined as an integer column will only hold numeric


information, whereas a column defined as a CHAR(10) will hold up to 10 alphanumeric
characters. These definitions are the key to a quick and efficient database. There are

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.

Numeric data can also be in hexadecimal format (2ee250cc), scientific notation


(2X10^23), or a decimal. The second type is character or string format. This format can
consist of letters and numbers, whole words, addresses, phone numbers, and generally
anything you have to put quotations around.

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.

They are AUTO_INCREMENT, UNSIGNED, PRIMARY KEY, NULL, NOT


NULL, and BINARY. A more detailed discussion of column modifiers takes place
following the coverage of the basic data types.

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

 Manual systems are more time consuming


 Large number of data is maintained.
 More possibilities for errors.
 Minimal Data security.
 Possibility for double entries.
 Updating of data is hard.
 Report generation.
 Damage to data.

3.2 PROPOSED 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.

 It automatically updates daily diet for the particular day.


 Error free and menu driven interface.
 Saves lot of time.
 Quick preparation of reports..
 user friendly environments for personalized information
 Continuous upgrade and maintenance.

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

TABLE NAME : FOODS

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

TABLE NAME : MEALS

PRIMARY KEY : NR

FIELD NAME DATA TYPE SIZE DESCRIPTION


NR INT 10 MEAL NUMBER
PLAN NR INT 10 PLAN NUMBER
DAY NR INT 10 NUMBER OF THE DAY
MEAL VARCHAR 10 TYPE OF THE MEAL
FOOD NR INT 10 FOOD NUMBER
FOOD_NAME VARCHAR 50 NAME OF THE FOOD

TABLE NAME : NUTRIENTS


14
PRIMARY KEY : FOOD NR

DATA
FIELD NAME SIZE DESCRIPTION
TYPE
FOOD NR INT 10 FOOD NUMBER
NUTRI NAME VARCHAR 25 NUTRITION NAME
VALUE VARCHAR 10 NUTRITIONAL VALUE

TABLE NAME : PLANS

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

4.4 INPUT DESIGN

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.

Input design of Food and diet Analyzer includes forms :

1. User details entry


2. User goal entry
3. Blood sugar level entry

User details entry


Administrator maintains records of all users. The user is allowed to enter their
name, age, address, date of birth along with their height and weight to create their own
profile. By which the user can have their own login with personal password.

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.

Blood sugar level entry


The user can enter their pre-prandial and post prandial sugar levels in this module
to get their diabetic food chart.

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.

Output design for Food and Diet Analyzer includes:


1. Reports, which displays
i. User profile
ii. User current plan
iii. Diet chart
iv. Diabetic food chart
2. User can identify the diet chart based on their height and weight.

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.

Unit Test Considerations


The tests that occur as part of unit testing. The module ‘interface’ is tested to
ensure that information properly flows into and out of the program unit under test. The
‘local data structures’ are examined to ensure that data stored temporarily maintains its
integrity during all steps in an algorithms execution.

‘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.

Unit Test Procedures


Unit testing is considered an equivalent to the coding step. After the source level
code has been developed, reviewed and verified for correct syntax, unit test case design
begins since a module is not a stand alone program, ‘driver’ and/or ‘stub’ S/W must be
developed for each unit test.

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.

There are three aspects of implementation,

1. Training personal
2. Conversion procedure
3. Post implementation review

After the system is implemented and conversion is complete a


review should be conducted to determine whether the system is meeting expectations and
where improvements are needed. A post implementation review measures the system’s
performance against predefined requirements. It determines how well the system
continues to meet performance specifications. I t also provides information to determine
whether a major re design or small modification is required.

The post implementation review is an evolution of a system in


terms of the extent to which the system accomplishes stated objectives and if the actual
project costs exceeds initial estimates. The post implementation study begins unexpected
changes in the system that affects the user or system performance is a primary factor that
prompts system 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.

After the programming is done, the coding is debugged by compiling. Then it is


executed by running the project. While executing all the values and fields are checked
and verified the report generation. Thus the system is implemented by testing the
specifications specified by the user efficiently.

23
6. SCOPE FOR FUTURE ENHANCEMENTS

This system is developed such a way that additional enhancement


can be done without difficulty. The renovation of the project would increase the
flexibility of the system. Also the features are provided in such a way that the system can
also be made better and efficient functionality.

The programs were coded in an easier and more structured manner


so that may further modifications may be incorporated easily.. This system has good
flexibility of accommodating any more changes that might arise in the future also.

In this system, improvements can be appended by changing the


existing modules of the system. The database is designed in such a way that it will be also
helpful for enhancement of the system.

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

1. Adam Trachtenberg, “PHP Cook Book”, Orreilly and Associates


Publication, First Edition, 2003.
2. Peter Moulding, “PHP Black Book”, Coriolis Group Publication, Fifth
Edition, 2005.
3. Dongosselin, “New PHP Program with MySQL”, Course Technology
Publication, 2008.
4. Robin Nikson, “Learning PHP, MySQL and JavaScript”, Orreilly and
Associates Publication, Third Edition, 2009.

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(isset($_SESSION['user']) && isset($_SESSION['pass'])){


$username=$_SESSION['user'];
$password=$_SESSION['pass'];

$s=mysql_query("SELECT UserType FROM users WHERE Username


='$username' AND PassMd ='$password'");
$count=mysql_num_rows($s);

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'];

mysql_query("UPDATE users SET FName = '$efname', MName = '$emname',


LName = '$elname', Address = '$eaddress', DoB = '$edob', Gender = '$egender',
Height = '$eheight', Weight = '$eweight' WHERE Username = '$user' AND PassMd =
'$pass'");

if (mysql_error()) {
$msg = 1;
$message = mysql_error();
} else {
$msg = 2;
$message = "Your Personal Information had been updated.";
}
}

$q = mysql_query("SELECT * FROM users WHERE Username = '$user' AND


PassMd = '$pass'");
$r = mysql_fetch_array($q);

$dob = $r['DoB'];
$height = $r['Height'];
$weight = $r['Weight'];
?>

<!doctype html>

<html lang="en" class="no-js">


<head>
<title>Food and Diet</title>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">


<meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1">

<link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen">


<link rel="stylesheet" type="text/css" href="css/font-awesome.css"
media="screen">
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/responsive.css" media="screen">

34
</head>

<body>

<!-- Container -->


<div id="container">
<!-- Header
==================================================
-->
<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="#"><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>

<!-- blog-box Banner -->


<div class="blog-box with-sidebar">
<div class="container">
<div class="row">
<h4 >Profile</h4>
<hr>
<?php
if ($msg == 1) {
?>
<div class="comment-form msg error"><?
php echo $message; ?></div>
<?php
}
else if ($msg == 2){
?>
<div class="comment-form msg
Success"><?php echo $message; ?></div>
<?php
}
?>
<div class="tabs-widget widget">
<ul class="tab-links">
<li style="width: 25%;"><a class="tab-link1 active"
href="#"> View</a></li>
<li style="width: 25%;"><a class="tab-link2"
href="#"> Update</a></li>

<li><a class="tab-link3"> &nbsp;</a></li>


</ul>
<div class="tab-box">
<div class="tab-content active">
<div class="leave-comment">
<h3>View Personal Information</h3>
<form class="comment-form"
method="post">
<div class="row">
<div class="col-md-10">

36
<div class="col-md-10">

<label style="float:left; width: 100%;">Name:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

echo $r['FName']. " " .$r['MName']. " " .$r['LName'];

?>

</p>

</div>

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

<label style="float:left; width: 100%;">Address:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

echo $r['Address'];

?>

</p>

</div>

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

<label style="float:left; width: 100%;">Birth:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

echo date("M d, Y", strtotime($dob));

?>

</p>

37
</div>

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

<label style="float:left; width: 100%;">Age:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

$birthdate = new DateTime($dob);

$today = new DateTime('today');

$age = $birthdate->diff($today)->y;

echo $age;

?>

</p>

</div>

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

<label style="float:left; width: 100%;">Gender:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

echo $r['Gender'];

?>

</p>

</div>

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

<label style="float:left; width: 100%;">Weight:</label>

38
<p style="font-size: 16px; margin-left: 5%;">

<?php

if ($weight == "") {

echo "Not yet defined.";

} else {

echo $weight. " lbs";

?>

</p>

</div>

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

<label style="float:left; width: 100%;">Height:</label>

<p style="font-size: 16px; margin-left: 5%;">

<?php

if ($height == "") {

echo "Not yet defined.";

} else {

echo $height. " in";

?>

</p>

</div>

</div>

39
<div><h1>BMI</h1>
<?php
$bmi = ($weight / ($height * $height)) * 703;

echo "<h3>".$bmi."</h3>";

if($bmi <= 18.5){

echo "<h3 style='color:#252525;'>Weight Status:</h3> Underweight";


}
else if($bmi >= 18.6 && $bmi <= 24.9){

echo "<h3 style='color:#252525;'>Weight Status:</h3> Normal";


}

else if($bmi >= 25.0 && $bmi <= 29.9){

echo "<h3 style='color:#252525;'>Weight Status:</h3> Overweight";


}
else if($bmi >= 30){

echo "<h3 style='color:#252525;'>Weight Status:</h3> Obese";

}
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">

<label style="float:left; width: 100%;">Name:</label>

<input type="text" name="fname" placeholder="First Name"


style="width: 30%; float: left; margin-left: 20px;" value="<?php echo $r['FName']; ?
>" required/>

<input type="text" name="mname" placeholder="Middle Name"


style="width: 30%; float: left; margin-left: 20px;" value="<?php echo $r['MName']; ?
>" required/>

<input type="text" name="lname" placeholder="Family Name"


style="width: 29%; float: left; margin-left: 20px;" value="<?php echo $r['LName']; ?
>" required/>

</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;" value="<?php echo $r['Address']; ?>" 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><?php echo $r['Gender']; ?></option>

<option>Male</option>

<option>Female</option>

</select>

</div>

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

41
<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;" value="<?php echo $dob; ?>" required/>

</div>

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

<label style="float:left; width: 100%;">Height (in):</label>

<input type="text" name="height" placeholder="Height" style="width:


90%; float: left; margin-left: 20px;" value="<?php echo $height; ?>" required/>

</div>

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

<label style="float:left; width: 100%;">Weight (lbs):</label>

<input type="text" name="weight" placeholder="Weight" style="width:


90%; float: left; margin-left: 20px;" value="<?php echo $weight; ?>" required/>

</div>

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

<input type="reset" value="Reset" style="width: 15%; height: 55px;


margin-right: 3%;"/>

<input type="submit" name="submit" value="Update" style="width: 15%;


height: 55px; margin-right: 3%;"/>

</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End content -->

42
<!-- footer

================================================== -->
<?php
include 'footer.html';
?>
<!-- End footer -->
</div>
<!-- End Container -->

<script type="text/javascript" src="js/jquery.min.js"></script>


<script type="text/javascript" src="js/jquery.migrate.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/retina-1.1.0.min.js"></script>
<script type="text/javascript" src="js/plugins-scroll.js"></script>
<script type="text/javascript" src="js/script.js"></script>

<!--[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']);

$q = mysql_query("SELECT UserType FROM users WHERE Username =


'$uname' AND PassMd = '$pword'") or die(mysql_error());
$num = mysql_num_rows($q);

$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'];

$q_user = mysql_query("SELECT Nr FROM users WHERE Username =


'$reg_user'");

$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);

mysql_query("INSERT INTO users (FName, MName, LName, DoB,


Gender, Height, Weight, Address, UserType, Username, Pass, PassMd) VALUES
('$fname', '$mname', '$lname', '$dob', '$gender','$height','$weight', '$address', 'user',
'$reg_user', '$reg_pass', '$md_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">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">


<meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1">

<link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen">


<link rel="stylesheet" type="text/css" href="css/font-awesome.css"
media="screen">
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/responsive.css" media="screen">
</head>
<body>

<!-- Container -->


<div id="container">
<!-- Header

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">

<!-- Page Banner -->


<div class="page-banner">
<div class="container">
<h2>Login/Registration Page</h2>
<ul class="page-tree">
<li><a href="index.php">Home</a></li>
<li><a
href="register.php">Login/Register</a></li>

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">

<label style="float:left; width: 100%;">Height (in):</label>

<input type="number" name="height" placeholder="" required/>

</div>

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

<label style="float:left; width: 100%;">Current Weight (lbs):</label>

<input type="number" name="weight" placeholder="" required/>

</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

You might also like