-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bmi.php
323 lines (311 loc) · 10.9 KB
/
Bmi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<?php
include 'connection.php';
session_start();
include 'config.php';
$bmi = "";
$weight1 = "";
$weight2 = "";
$weight3 = "";
$range = "";
$loose = "";
$redi = "";
$cnt = 0;
if (isset($_SESSION['id'])) {
$user = $_SESSION['uname'];
$age = $_SESSION['age'];
$weight = $_SESSION['weight'];
$height = $_SESSION['height'];
$gender = $_SESSION['gender'];
$heightm = $height / 100;
$bmi = $weight / ($heightm ** 2);
$IDEAL_BMI_LOWER = 18.5 * ($heightm ** 2);
$IDEAL_BMI_UPPER = 25 * ($heightm ** 2);
$bmi = number_format((float)$bmi, 1, '.', '');
//Bmr-----------
if ($gender == "Male") {
$bmr = (10 * $weight) + (6.25 * ($heightm * 100)) - (5 * $age) + 5;
} else {
$bmr = (10 * $weight) + (6.25 * ($heightm * 100)) - (5 * $age) - 161;
}
$kal = 4.184 * $bmr;
//Bmi------------
if ($bmi < 18.5) {
$range = "Underweight";
$weight3 = $IDEAL_BMI_LOWER - $weight;
$weight3 = (int)$weight3;
$loose = $weight3;
$suffix = "Kgs";
} else if ($bmi < 25) {
$range = "Normal (healthy weight)";
$weight3 = "";
$suffix = "";
} else if ($bmi < 30) {
$range = "overweight";
$weight3 = $weight - $IDEAL_BMI_UPPER;
$weight3 = (int)$weight3;
$loose = $weight3;
$suffix = " Kgs";
} else if ($bmi < 35) {
$range = "class I obese";
$weight3 = $weight - $IDEAL_BMI_UPPER;
$weight3 = (int)$weight3;
$suffix = " Kgs";
} else if ($bmi < 40) {
$range = "class II obese";
$weight3 = $weight - $IDEAL_BMI_UPPER;
$weight3 = (int)$weight3;
$suffix = " Kgs";
} else {
$range = "class III obese";
$weight3 = $weight - $IDEAL_BMI_UPPER;
$weight3 = (int)$weight3;
$suffix = " Kgs";
}
if ($bmi > 18.5 && $bmi < 25) {
$statement = " ";
$recommendation = " ";
} else {
if ($bmi < 18.5) {
$statement = "A little effort away from your ideal weight";
$recommendation = "We recommend you to Gain " . $weight3;
} else {
$statement = "A little effort away from your ideal weight";
$recommendation = "We recommend you to Lose " . $weight3;
}
}
// Flooring values
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$bmr = (int)$bmr;
$IDEAL_BMI_LOWER = (int)$IDEAL_BMI_LOWER;
$IDEAL_BMI_UPPER = (int)$IDEAL_BMI_UPPER;
$id = $_SESSION["id"];
$ins_status = "";
if ($cnt == 0) {
$ins = "INSERT INTO bmi (id,name,age,weight,height,gender,bmi,bmr,upper_weight,lower_weight,bmi_range) VALUES ('$id','$user','$age','$weight','$height','$gender','$bmi','$bmr','$IDEAL_BMI_UPPER','$IDEAL_BMI_LOWER','$range')";
if ($conn->query($ins) === TRUE) {
$cnt++;
$ins_status = "Insterted";
} elseif ($cnt == 1) {
$ins_status = "Insterted Once";
} else {
$ins_status = "Not Inserted";
}
}
}
?>
<!-- PHP End -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Bmi-Home</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800;900&family=Roboto:wght@500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src='main.js'></script>
</head>
<body id="bd_bmi">
<div class="container">
<div class="row">
<div class="card1">
<p>
<span class="textbmi"> Your BMI: </span>
<span class="counter"> <?php echo $bmi ?> </span>
</p>
</div>
<div class="card2">
<p class="textbmi">Your BMR: <span class="counter1"> <?php echo $bmr; ?> </span>
<span class="cal">cal</span>
</p>
</div>
<div class="card3">
<p>Ideal Weight Range: <span id="idl_weight">
<span class="counter1"> <?php echo " " . $IDEAL_BMI_LOWER ?> </span>
<span>-</span>
<span class="counter1"> <?php echo " " . $IDEAL_BMI_UPPER ?> </span>
</span> Kgs </p>
</div>
</div>
<div class="row">
<div class="card4">
<p id="statement">
<span> <?php echo $range; ?> </span>
</p>
<p id="statement">
<span> <?php echo $statement; ?> </span>
</p>
</div>
</div>
<div class="row">
<div class="card5">
<h3>What is BMI ?</h3>
<p> The body mass index calculator measurement is the calculation of your body weight in relation to your height and is commonly used as an indicator of whether you might be in a risk category for health problems caused by your weight.</p>
<div class="ref">
<h5>
<strong> Reference:</strong>
</h5>
<p>
<p id="note">Calculations are performed on the basis of Mifflin - St Jeor equation</p>
<a href="https://www.nhlbi.nih.gov/files/docs/guidelines/prctgd_c.pdf"><small> <p>Practical Guide: National Institutes of Health (NIH), National Heart, Lung, and Blood Institute (NHLBI).</p></small></a>
</p>
</div>
</div>
<div class="card6">
<h3> BMI Classification Table </h3>
<table class="table table-borderless table-sm">
<thead>
<tr>
<th scope="col">Body Mass Index</th>
<th scope="col">Classification</th>
</tr>
</thead>
<tbody>
<tr>
<td>Less than 18.5: </td>
<td>Underweight</td>
</tr>
<tr>
<td>18.5 - 24.9:</td>
<td>Normal Weight</td>
</tr>
<tr>
<td>25 - 29.9: </td>
<td>Overweight</td>
</tr>
<tr>
<td>30 - 34.9: </td>
<td>Class I Obese</td>
</tr>
<tr>
<td>35 - 39.9: </td>
<td>Class II Obese</td>
</tr>
<tr>
<td>40 upwards: </td>
<td>Class III Obese</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="card7">
<h3>What is BMR ? </h3>
<p> The Basal Metabolic Rate (BMR) Calculator estimates your basal metabolic rate-the amount of energy expended while at rest in a neutrally temperate environment. </p>
<div class="bmrsdetails">
<h3>Your BMR Summary</h3>
<p> Your body will burn <b>
<span> <?php echo $bmr ?> </span> calories( <span> <?php echo (int)$kal; ?> </span> kJ) </b> each day if you engage in no activity for that day. The estimate for maintaining your current weight (based upon your chosen activity level) is <b>
<span> <?php echo (int)(1.2 * $bmr) ?> </span> calories ( <span> <?php echo (int)(1.2 * $kal) ?> </span> kJ). </b> </p>
</div>
</div>
<div class="card8">
<h3>BMR Table</h3>
<table class="table table-borderless table-m" id="bmrtbl">
<thead>
<tr>
<th scope="col">Activity level </th>
<th scope="col">BMR</th>
</tr>
</thead>
<tbody>
<tr>
<td> Little / No Exercise </td>
<td> <?php echo (int)($bmr * 1.2) ?> </td>
</tr>
<tr>
<td> Light Exercise / Sports 1-3 Days per week </td>
<td> <?php echo (int)($bmr * 1.375) ?> </td>
</tr>
<tr>
<td>Moderate Exercise / Sports 3-5 Days per week </td>
<td> <?php echo (int)($bmr * 1.55) ?> </td>
</tr>
<tr>
<td> Intense Exercise / Sports 6-7 Days per week </td>
<td>
<span> <?php echo (int)($bmr * 1.725) ?> </span>
</td>
</tr>
<tr>
<td> Very Intense Exercise / Physical Job </td>
<td> <?php echo (int)($bmr * 1.9) ?> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="card9">
<h4>
<p> Are You Want to lose or gain Weight</p>
<p id="choice">Yes <input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="yesCheck">
No <input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="noCheck" checked></p>
</h4>
</div>
</div>
<div class="row" id="r6">
<div class="card10" id="ifyes" style="display:none;">
<span>
<strong> <?php echo $recommendation . " " . $suffix; ?> </strong>
</span>
<form method="POST" name="diet" action="Plan.php" id="Plan_Form">
<h6>
<p> Daily activity: <select name="activityLevel">
</p>
<option value="1.2">Desk job, little/no exercise</option>
<option value="1.375">Light exercise 1-3 days/wk</option>
<option value="1.55"> Moderate exercise 3-5 days/wk</option>
<option value="1.725"> Hard exercise 6-7 days/wk</option>
<option value="1.9"> Physical job & hard daily exercise</option>
</select>
</h6>
<table align="center" id="tbl">
<thead>
<tr>
<th id="th">Your Goals</th>
<th id="th">Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Want to <select name="loseGain">
<option value="0">Lose</option>
<option value="1">Gain</option>
</select>: <br>
</td>
<td id>
<input type="number" step="any" name="aim" value="<?php echo $weight3 ?>" placeholder="Weight in kgs" required>
</td>
</tr>
<tr>
<td>
<select name="periodType">
<option value="1">Days</option>
<option value="7">Weeks</option>
<option value="30.4" selected>Months</option>
<option value="365">Years</option>
</select> to achieve goal:
</td>
<td >
<input type="number" step="any" name="periodNum" value="3" required>
</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-s text-center" name="diet" id="sbmtBtn">Next</button>
</form>
</div>
</div>
</div>
<div id="beforepage"></div>
</body>
</html>