-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.php
executable file
·70 lines (52 loc) · 1.33 KB
/
calculator.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
<?
// Start session
session_start();
// Include required functions file
require_once('includes/functions.inc.php');
// Check login status... if not logged in, redirect to login screen
if (check_login_status() == false) {
redirect('login.php');
}
?>
<script>
<!--
function calculate() {
var doc = document.pointCalc;
var points = 0;
var fiber = doc.fiber.value;
var fat = doc.fat.value;
var calories = doc.calories.value;
points = (calories / 50) + (fat / 12) - (fiber / 5);
doc.result.value = Math.round(points);
}
// -->
</script>
<?php require_once('menu.php');?>
<div id="page">
<div id="page-bg">
<h2>Calculate Points of Food Without Adding to Tracker</h2>
<form name="pointCalc">
<table><tr>
<tr><td>Calories:</td><td><input type="text" name="calories"></td></tr>
<tr><td>Fat:</td><td><input type="text" name="fat"></td></tr>
<tr>
<td>Fiber:</td>
<td>
<select name="fiber">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4 or more</option>
</select>
</td>
</tr>
<tr><td align = 'right' colspan="2"><input type="button" value="Calculate" onClick="calculate();"></td></tr>
<tr><td><b>Points: </td><td><input type="text" name="result"></td></b></tr>
</table>
</form>
</div>
</td></tr></table>
</div>
</body>
</html>