-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretrieve.php
36 lines (36 loc) · 1.11 KB
/
retrieve.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
<html>
<head>
<?php
session_start();
$q = strval($_GET['q']);
$con = mysqli_connect('localhost','root','','calorie_updater');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
$sql="SELECT calories FROM `foodcal` WHERE food = '".$q."'";
$result = mysqli_query($con,$sql);
$q = mysqli_query($con, $sql);
$qq = mysqli_fetch_assoc($q);
$cal = $_SESSION['calorie'];
echo "Calorie count:";
$cal = $cal-$qq['calories'];
echo $cal;
$_SESSION['calorie'] = $cal;
if($cal <=0){
$var = $_SESSION['username'];
$email = "SELECT email from `registered_users` where username= '$var'";
$q = mysqli_query($con, $email);
$qq = mysqli_fetch_assoc($q);
/*$email_to = $qq['email'];
$email_subject = "Notification";
$email_message = "The calorie count for this day has exceeded.Stay fit.Have a nice day!";
$headers = "From: The Calorie Updater Team\r\n".
"Reply-To: [email protected]\r\n'" .
"X-Mailer: PHP/" . phpversion();
mail($email_to, $email_subject, $email_message, $headers); */
echo "\n<br>The calorie count for this day has exceeded.";
}
mysqli_close($con);
?>
</body>
</html>