-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisLoggedIn.php
41 lines (32 loc) · 876 Bytes
/
isLoggedIn.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
<?php
if(isset($_SESSION['user'])){
$user = $_SESSION['user'];
include_once('dbConnect.php');
$sql = "SELECT * FROM User_info i, User_body b WHERE i.userID = $user AND b.userID = $user";
$result = $conn->query($sql);
try
{
if($user)
{
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$_SESSION['user_weight'] = $row['current_weight'];
$_SESSION['user_height'] = $row['height'];
$_SESSION['user_age'] = $row['age'];
}
}
}
else
{
throw new Exception("You must be logged in to review your account information");
}
}
catch(Exception $e)
{
echo $e->getMessage();
}
}
else {
echo "You must be logged in to complete this action";
}
?>