Diet Planner Project in PHP with Source Code and Report
By Prakash Panthi, Founder · Published October 2, 2026
A diet planner project in PHP (also submitted as a diet management or nutrition management system) is a good final-year title for BCA, MCA, B.Tech and BSc IT students: it is small enough to finish, it has real formulas to explain, and it has rules that have to be enforced in the database. This guide walks through what a complete one contains, the formulas behind it, how to run it on XAMPP, what the project report must cover and the viva questions to expect. The worked example is our Diet & Meal Planner in PHP: plain PHP and MySQL, 8 tables, no framework.
What a diet planner system does
There are two kinds of user. The dietitian (staff) logs in and manages everything. The client opens a private link to see their plan and report their weight.
- Clients: height, date of birth, sex, activity level, goal (lose, maintain, gain), diet preference (vegan, vegetarian, vegetarian + eggs, non-vegetarian), allergies, target weight.
- Weight tracking: one weigh-in per client per day, BMI for each entry, a progress chart.
- Calculator: BMI, resting energy and daily energy use from standard formulas.
- Food database: 125 foods with energy, protein, carbohydrate, fat and fibre per 100 g, plus a household measure such as a cup or a piece.
- Meal plans: 1 to 14 days, six meals a day; each food added shows its calories and macros and each day is totalled against the client's target.
- Templates, copy-day and print view, and a rule that a client has only one active plan.
The formulas you must be able to explain
BMI
Body mass index = weight in kilograms ÷ (height in metres)². A person of 70.4 kg and 162 cm has a BMI of 70.4 ÷ 1.62² = 26.8. The WHO adult ranges are: under 18.5 underweight, 18.5–24.9 normal, 25–29.9 overweight, 30 and over obese. These ranges are for adults, so the system does not show them for clients under 18.
Resting energy (Mifflin-St Jeor)
Resting energy = 10 × weight (kg) + 6.25 × height (cm) − 5 × age (years), then + 5 for men or − 161 for women. A woman of 30 years, 165 cm and 60 kg: 600 + 1031.25 − 150 − 161 = 1,320 kcal a day.
Daily energy use
Resting energy × an activity multiplier: 1.2 sedentary, 1.375 lightly active, 1.55 moderately active, 1.725 very active, 1.9 extra active. For the same woman at moderate activity: 1,320 × 1.55 = 2,046 kcal.
Macronutrient grams
Protein and carbohydrate give 4 kcal per gram and fat gives 9. A 1,500 kcal target split 25% protein, 45% carbohydrate, 30% fat is 94 g protein, 169 g carbohydrate and 50 g fat.
Say clearly in your report that these are population estimates used for planning, not measurements and not medical advice.
The database design examiners ask about
| Table | Purpose |
|---|---|
clients | Profile, measurements, goal, diet preference, targets, private link key |
weight_logs | Weigh-ins; unique key on (client, date) |
foods | Values per 100 g, household measure, diet type, source |
meal_plans | A plan or a template; status; active_key |
plan_items | Day, meal, food, quantity, and a stored copy of the nutrient amounts |
admin_users, login_attempts, counters | Login, lockout, numbering |
Three design decisions are worth a viva answer each:
- One active plan per client, enforced by the database.
meal_plans.active_keyholds the client id while a plan is active and NULL otherwise. A unique index ignores NULLs, so many drafts can exist but only one active row per client. - A plan line stores its own numbers.
plan_itemskeeps the food name and the calories, protein, carbohydrate and fat for the quantity entered. Editing or deleting a food later does not change a plan already printed — the same idea as an invoice line keeping the price at the time of sale. - One weigh-in per day. The unique key on (client, date) with
INSERT … ON DUPLICATE KEY UPDATEturns a second entry into an update, even when two requests arrive together.
Running it on XAMPP
- Install XAMPP and start Apache and MySQL.
- Copy the
diet_plannerfolder intohtdocs. - In phpMyAdmin create a database
diet_plannerand importsql/schema.sql— 8 tables and 125 foods. - Check the four
DB_*values inconfig.php. - Open
http://localhost/diet_planner/login.php, log in with admin / admin123 and change the password. - Add a client, record a weigh-in, set a target, build day 1 of a plan and activate it. Then open the client's private link in a private window.
What the project report must contain
| Chapter | For a diet planner |
|---|---|
| Abstract and introduction | The problem (plans built by hand, totals added manually, weights scattered in chats), objectives, scope and what is out of scope. |
| System analysis | Existing vs proposed system, feasibility, functional and non-functional requirements. |
| System design | Architecture, the two users, modules with their tables, DFD level 0 and 1, ER relationships, use cases. |
| Database design | Every table with columns, types and keys, taken from the real schema. |
| Implementation | The formulas, how a food is added to a plan, how activation works, security measures, declaration of any licensed base. |
| Testing | BMI and energy worked examples, duplicate weigh-in, diet preference refusal, second active plan, wrong link key, injection attempt. |
| Conclusion and future scope | Recipe builder, micronutrients, several dietitians, reminders. |
The product download includes a college-project-pack folder with this report as a Word template — the database chapter is generated from the real schema — plus 29 viva questions with answers. See PHP projects for college students.
Sample viva questions
Q. Which equation gives the calorie estimate?
Mifflin-St Jeor for resting energy, multiplied by an activity factor from 1.2 to 1.9. It is validated for adults, so the system shows it only from age 18.
Q. How do you stop a vegetarian client being given chicken?
The four diets are an ordered list. A function checks on the server that the food's position is not after the client's, every time a food is added or a plan is copied.
Q. How does the client see the plan without a login?
Each client has a random 32-character key in their link. The page validates the key, looks it up with a prepared statement and shows only that client's active plan. Staff can replace the key.
Q. Where does the food data come from?
USDA FoodData Central (SR Legacy), which is in the public domain. Each food stores the record it came from.
How to make it your own
- Add a recipe builder that combines foods into a dish and stores its values per serving.
- Add a water-intake log on the client's page.
- Add micronutrients such as sodium, calcium and iron to foods and day totals.
- Add separate logins for several dietitians.
Whichever you choose, update the ER list, the test cases and the conclusion so the report describes the system you demonstrate.
A word on originality
Using licensed source code as a base is fine when it is declared. Keep the declaration paragraph in the implementation chapter, add your own feature, write the report in your own words and check your university's plagiarism policy.
Start here: the Diet & Meal Planner in PHP — source code, database with 125 foods, report template and viva questions in one download.
Our Diet & Meal Planner
Includes the matching database file and email support — why that's worth it over a free download.
View Diet & Meal Planner →