forked from LahiruSen/OOSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
l_profile_change.php
119 lines (73 loc) · 2.09 KB
/
l_profile_change.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
session_start();
require 'db.php';
if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['message'] = "You must log in before viewing your profile page!";
header("location: error.php");
}
elseif($_SESSION['active'] != 1)
{
$_SESSION['message'] = "We have sent you a verification email to your email account. Please click verification link to verify your account!!!";
header("location: error.php");
} else
{
// Makes it easier to read
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$active = $_SESSION['active'];
$types = $_SESSION['types'];
$two_step= $_SESSION['two_step'];
//user data
$result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error());
if($result->num_rows ==0)
{
$_SESSION['message'] = "This user is not a valid user!!!";
header("location: error.php");
} else
{
$user = $result->fetch_assoc();
$result->free();
$userId = $user['id'];
$_SESSION['user_id'] = $userId;
//get students or employee data if available
if( $types == 2)
{
$student_result = $mysqli->query("SELECT * FROM student_data WHERE user_id='$userId'") or die($mysqli->error());
$ayear_result = $mysqli->query("SELECT * FROM academic_year WHERE status=1") or die($mysqli->error());
if($ayear_result->num_rows != 0)
{
$ayear_data = $ayear_result->fetch_assoc();
$ayear_result->free();
}
if($student_result->num_rows != 0)
{
$student_data = $student_result->fetch_assoc();
$student_result->free();
}
}
else
{
$employee_result = $mysqli->query("SELECT * FROM employee_data WHERE user_id='$userId'") or die($mysqli->error());
$employee_types_result = $mysqli->query("SELECT * FROM employee_types") or die($mysqli->error());
if($employee_types_result->num_rows ==0)
{
$_SESSION['message'] = "No Employee types found ";
header("location: error.php");
}else
{
$employee_types_data = array();
while ($row = $employee_types_result->fetch_assoc())
{
$employee_types_data[] = $row;
}
$employee_types_result->free();
}
if($employee_result->num_rows != 0)
{
$employee_data = $employee_result->fetch_assoc();
$employee_result->free();
}
}
}
}
?>