├── Database.php ├── README.md ├── attendance_monitoring.sql ├── lecturerLogin ├── DBOperations.php ├── Functions.php └── index.php ├── lecturerModuleGet.php ├── lecturerStatusClear.php ├── studentAttendanceGet.php ├── studentLogin ├── DBOperations.php ├── Functions.php └── index.php ├── studentModuleGet.php ├── studentModuleUpdate.php └── studentStatusGet.php /Database.php: -------------------------------------------------------------------------------- 1 | close(); 33 | } 34 | 35 | function unsafeQueryExec($query) { 36 | $conn = $this->getConnection(); 37 | 38 | $results = $conn->query($query); 39 | 40 | $conn->close(); 41 | 42 | return $results; 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MySQL-database-for-Attendance-monitoring-system 2 | MySQL database for the project "phone app for attendance monitoring" 3 | This project is part of my "Phone app for attendance monitoring system" project. The system consists of three part 4 | 5 | 1. Android App for student to check-in to the class (https://github.com/landtanin/StudentAttendanceCheck) 6 | 2. Android App for teacher to monitor student's attendance (https://github.com/landtanin/TeacherAttendanceMonitoring) 7 | 3. MySQL database PHP server (this repo) 8 | -------------------------------------------------------------------------------- /attendance_monitoring.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.7.0 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: localhost:3306 6 | -- Generation Time: Jan 20, 2018 at 03:52 AM 7 | -- Server version: 5.7.17 8 | -- PHP Version: 7.1.2 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET AUTOCOMMIT = 0; 12 | START TRANSACTION; 13 | SET time_zone = "+00:00"; 14 | 15 | 16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 19 | /*!40101 SET NAMES utf8mb4 */; 20 | 21 | -- 22 | -- Database: `attendance_monitoring` 23 | -- 24 | 25 | -- -------------------------------------------------------- 26 | 27 | -- 28 | -- Table structure for table `lecturerinfo` 29 | -- 30 | 31 | CREATE TABLE `lecturerinfo` ( 32 | `_id` int(11) NOT NULL, 33 | `name` text NOT NULL, 34 | `lecturerId` int(11) NOT NULL 35 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 36 | 37 | -- 38 | -- Dumping data for table `lecturerinfo` 39 | -- 40 | 41 | INSERT INTO `lecturerinfo` (`_id`, `name`, `lecturerId`) VALUES 42 | (1, 'Kristof Cools', 1), 43 | (2, 'Nothofer Angela', 2), 44 | (3, 'Phil Sewell', 3), 45 | (4, 'James Bonnyman', 4), 46 | (5, 'Alessandro Costabeber', 5), 47 | (6, 'John Crowe', 6), 48 | (7, 'Steve Sharples', 7); 49 | 50 | -- -------------------------------------------------------- 51 | 52 | -- 53 | -- Table structure for table `lecturermodule` 54 | -- 55 | 56 | CREATE TABLE `lecturermodule` ( 57 | `_id` int(11) NOT NULL, 58 | `Lecturer_id` int(11) NOT NULL, 59 | `Module_id` varchar(8) NOT NULL 60 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 61 | 62 | -- 63 | -- Dumping data for table `lecturermodule` 64 | -- 65 | 66 | INSERT INTO `lecturermodule` (`_id`, `Lecturer_id`, `Module_id`) VALUES 67 | (1, 1, 'MA0001'), 68 | (4, 1, 'H63JAV-1'), 69 | (6, 3, 'H63ESD'), 70 | (7, 4, 'TEL001'), 71 | (8, 6, 'H63BPE-1'), 72 | (9, 6, 'H63BPE-2'), 73 | (10, 1, 'JAV001'), 74 | (12, 4, 'TLC001'), 75 | (13, 2, 'JAP001'), 76 | (14, 1, 'H63JAV-2'); 77 | 78 | -- -------------------------------------------------------- 79 | 80 | -- 81 | -- Table structure for table `lecturer_users` 82 | -- 83 | 84 | CREATE TABLE `lecturer_users` ( 85 | `_id` int(11) NOT NULL, 86 | `unique_id` varchar(23) NOT NULL, 87 | `name` varchar(50) NOT NULL, 88 | `lecturer_id` int(10) NOT NULL, 89 | `email` varchar(50) NOT NULL, 90 | `encrypted_password` varchar(256) NOT NULL, 91 | `salt` varchar(10) NOT NULL, 92 | `created_at` datetime DEFAULT NULL 93 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 94 | 95 | -- 96 | -- Dumping data for table `lecturer_users` 97 | -- 98 | 99 | INSERT INTO `lecturer_users` (`_id`, `unique_id`, `name`, `lecturer_id`, `email`, `encrypted_password`, `salt`, `created_at`) VALUES 100 | (1, '58f7a32aec0639.73079853', 'Kristof Cools', 1, 'kristof@cools.com', '$2y$10$hMNkFGUAc8wvzBav17OXJeAbS4QydB4sEbYb3tJEjcv12BJeDsmaG', '13e145006c', '2017-04-19 17:49:31'), 101 | (2, '58f8b6c3e32bc1.60752956', 'Nothofer Angela', 2, 'nothofer@angela.com', '$2y$10$sop1vU6CnzaSLyQFpR09vuC6CfJ5UsRykkrMjrp2Z1x/HjdA5jsaW', '68fb45ba39', '2017-04-20 13:25:24'), 102 | (3, '58f8b71b8dd114.54569734', 'Phil Sewell', 3, 'phil@sewell.com', '$2y$10$Phnp3M36lm2HfzjfPvEAN.Oiw9Jc7MFVlpyULf9WIvR9kXp2kPUAy', '888b6c6734', '2017-04-20 13:26:51'), 103 | (4, '58f8b733ab1410.95755606', 'James Bonnyman', 4, 'james@bonnyman.com', '$2y$10$UStja5R4FfHHKDY9t4cPeeECRgx.XLMTXbafN2bDyO1vb5ffLj7Aq', '6c121e87b9', '2017-04-20 13:27:15'), 104 | (5, '58f8b750d89df6.97184707', 'Allessandro Coastabeber', 5, 'allessandro@coastabeber.com', '$2y$10$3Ql5fLvqu.wjr4tUOHJlwunah6xR11AhppAWR.cwx3jgVqLXZJAoS', '90a67105b0', '2017-04-20 13:27:44'), 105 | (6, '58f8b764aa7e50.31910209', 'John Crowe', 6, 'john@crowe.com', '$2y$10$ZN0SRsAMAuij7sg9tiPu.uUe0CSmYYMJVWivWVsVqbDOacDA3LsdK', 'db251c3515', '2017-04-20 13:28:04'), 106 | (7, '58f8b777ed9b13.76815159', 'Steve Sharples', 7, 'steve@sharples.com', '$2y$10$MF4n8cAMdqIQ55vwYhCnNuE8PlL47PIG2O.cBHuiiXAdy9do6LvFG', '2549ed2779', '2017-04-20 13:28:24'); 107 | 108 | -- -------------------------------------------------------- 109 | 110 | -- 111 | -- Table structure for table `moduleinfo` 112 | -- 113 | 114 | CREATE TABLE `moduleinfo` ( 115 | `_id` int(11) NOT NULL, 116 | `name` text NOT NULL, 117 | `moduleId` varchar(8) NOT NULL, 118 | `startDate` datetime DEFAULT NULL, 119 | `endDate` datetime DEFAULT NULL, 120 | `checkInStart` datetime DEFAULT NULL, 121 | `checkInEnd` datetime DEFAULT NULL, 122 | `room` text NOT NULL, 123 | `LocLat` double DEFAULT NULL, 124 | `LocLng` double NOT NULL, 125 | `ModStatus` text NOT NULL, 126 | `Day` varchar(3) NOT NULL, 127 | `Lecturer` text NOT NULL 128 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 129 | 130 | -- 131 | -- Dumping data for table `moduleinfo` 132 | -- 133 | 134 | INSERT INTO `moduleinfo` (`_id`, `name`, `moduleId`, `startDate`, `endDate`, `checkInStart`, `checkInEnd`, `room`, `LocLat`, `LocLng`, `ModStatus`, `Day`, `Lecturer`) VALUES 135 | (1, 'Mathematic for super cool engineer ', 'MA0001', '2017-01-15 09:40:00', '2018-07-17 12:44:00', '2017-04-16 09:38:00', '2017-04-16 09:42:00', 'Coates', 52.94119, -1.189594, 'inactive', 'Sat', 'Kristof Cools'), 136 | (2, 'Interview', 'JAV001', '2017-01-16 09:40:00', '2018-07-17 10:40:00', '2017-04-16 09:39:00', '2017-04-16 10:21:00', 'Charnwood Building', 52.758847, -1.246605, 'inactive', 'Wed', 'Kristof Cools'), 137 | (3, 'JAPAN', 'JAP001', '2017-01-17 08:36:00', '2018-07-17 08:43:00', '2017-04-16 08:35:00', '2017-04-16 08:37:00', 'Portland', 51.513613, -0.136499, 'inactive', 'Mon', 'Nothofer Angela'), 138 | (4, 'PHP', 'PHP001', '2017-01-18 00:00:00', '2018-07-17 00:00:00', '2017-04-16 08:45:00', '2017-04-16 09:15:00', 'Tower Building', 52.942368, -1.188579, 'inactive', 'Mon', 'Phil Sewell'), 139 | (6, 'TeleElec', 'TLC001', '2017-01-01 20:47:00', '2018-07-17 22:58:00', '2017-04-16 20:20:00', '2017-04-16 22:57:00', 'Coates', 52.94119, -1.188579, 'inactive', 'Tue', 'James Bonnyman'), 140 | (7, 'Telecom2', 'TEL001', '2017-01-01 20:25:00', '2018-07-17 21:42:00', '2017-04-16 20:20:00', '2017-04-09 21:40:00', 'Coates', 52.94119, -1.189594, 'inactive', 'Fri', 'Alessandro Costabeber'), 141 | (27, 'Web Based Computing', 'H63JAV-2', '2017-02-01 23:13:00', '2018-07-17 23:15:00', '2017-04-17 23:12:00', '2017-04-17 23:14:00', 'ESLC-B14', 52.941475, -1.189167, 'inactive', 'Wed', 'Kristof Cools'), 142 | (28, 'Web Based Computing', 'H63JAV-1', '2017-02-01 09:00:00', '2018-07-17 11:00:00', '2017-04-17 09:08:00', '2017-04-17 09:15:00', 'Tower Building 308', 52.942368, -1.188579, 'inactive', 'Mon', 'Kristof Cools'), 143 | (29, 'Business Planning for engineers', 'H63BPE-1', '2017-02-01 12:00:00', '2018-07-17 13:00:00', '2017-04-17 11:45:00', '2017-04-17 12:15:00', 'Tower Building 203', 52.942368, -1.188579, 'inactive', 'Mon', 'John Crowe'), 144 | (30, 'Business Planning for Engineers', 'H63BPE-2', '2017-02-01 12:00:00', '2018-07-17 17:30:00', '2017-04-17 11:45:00', '2017-04-17 12:15:00', 'POPE C17', 52.941032, -1.190089, 'inactive', 'Wed', 'John Crowe'), 145 | (31, 'Telecommunication Electronics', 'H63TCE', '2017-02-01 09:00:00', '2018-07-17 11:00:00', '2017-04-17 08:45:00', '2017-04-17 09:15:00', 'Tower Building 203', 52.942368, -1.188579, 'inactive', 'Tue', 'Steve Sharples'), 146 | (32, 'Engineering Software: Design and Implementation', 'H63ESD', '2017-02-01 00:25:00', '2018-07-17 17:30:00', '2017-04-17 01:23:00', '2017-04-17 17:27:00', 'PSYC-A16', 52.939483, -1.189159, 'inactive', 'Fri', 'Phil Sewell'); 147 | 148 | -- -------------------------------------------------------- 149 | 150 | -- 151 | -- Table structure for table `studentinfo` 152 | -- 153 | 154 | CREATE TABLE `studentinfo` ( 155 | `_id` int(11) NOT NULL, 156 | `name` text NOT NULL, 157 | `student_id` int(11) NOT NULL, 158 | `course` text NOT NULL, 159 | `AVG` int(11) NOT NULL, 160 | `AttendanceStatus` text NOT NULL 161 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 162 | 163 | -- 164 | -- Dumping data for table `studentinfo` 165 | -- 166 | 167 | INSERT INTO `studentinfo` (`_id`, `name`, `student_id`, `course`, `AVG`, `AttendanceStatus`) VALUES 168 | (1, 'JOHN DOE', 1, 'Electrical and Electronic Engineering', 70, 'end'), 169 | (2, 'HARRY POTTER', 2, 'Electronic and Computer Engineering', 60, 'end'), 170 | (3, 'ROWAN ATKINSON', 3, 'Electrical Engineering', 50, 'end'), 171 | (4, 'TONY STARK', 4, 'Electrical Engineering', 90, 'end'), 172 | (5, 'TANIN ROJANAPIANSATITH', 4256422, 'Electronic and computer Engineering', 100, 'end'); 173 | 174 | -- -------------------------------------------------------- 175 | 176 | -- 177 | -- Table structure for table `studentmodule` 178 | -- 179 | 180 | CREATE TABLE `studentmodule` ( 181 | `_id` int(11) NOT NULL, 182 | `Student_id` int(11) NOT NULL, 183 | `Module_id` varchar(8) NOT NULL, 184 | `status` varchar(8) DEFAULT NULL 185 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 186 | 187 | -- 188 | -- Dumping data for table `studentmodule` 189 | -- 190 | 191 | INSERT INTO `studentmodule` (`_id`, `Student_id`, `Module_id`, `status`) VALUES 192 | (2, 1, 'JAV001', 'checked'), 193 | (7, 3, 'JAP001', 'end'), 194 | (8, 3, 'PHP001', 'end'), 195 | (9, 4, 'PHP001', 'end'), 196 | (10, 4, 'TLC001', 'end'), 197 | (11, 1, 'TEL001', 'end'), 198 | (12, 1, 'TLC001', 'end'), 199 | (13, 1, 'JAP001', 'end'), 200 | (15, 4256422, 'H63JAV-1', 'end'), 201 | (16, 4256422, 'H63JAV-2', 'end'), 202 | (17, 4256422, 'H63BPE-1', 'end'), 203 | (18, 4256422, 'H63BPE-2', 'end'), 204 | (19, 4256422, 'H63TCE', 'end'), 205 | (20, 4256422, 'H63ESD', 'end'), 206 | (23, 4, 'JAV001', 'checked'), 207 | (28, 3, 'MA0001', 'end'), 208 | (29, 2, 'MA0001', 'end'), 209 | (30, 2, 'MA0001', 'end'), 210 | (31, 3, 'MA0001', 'end'), 211 | (32, 3, 'JAV001', 'end'), 212 | (33, 2, 'JAV001', 'end'), 213 | (34, 2, 'JAV001', 'end'), 214 | (35, 3, 'JAV001', 'end'), 215 | (37, 4256422, 'H63JAV-2', 'end'), 216 | (43, 1, 'MA0001', 'end'), 217 | (44, 4, 'TEL001', 'end'), 218 | (45, 4, 'JAP001', 'end'), 219 | (46, 1, 'H63JAV-2', 'end'), 220 | (47, 4, 'H63JAV-2', 'end'), 221 | (49, 4, 'JAV001', 'checked'), 222 | (50, 4, 'JAV001', 'checked'); 223 | 224 | -- -------------------------------------------------------- 225 | 226 | -- 227 | -- Table structure for table `student_users` 228 | -- 229 | 230 | CREATE TABLE `student_users` ( 231 | `_id` int(11) NOT NULL, 232 | `unique_id` varchar(23) NOT NULL, 233 | `name` varchar(50) NOT NULL, 234 | `student_id` int(10) NOT NULL, 235 | `email` varchar(50) NOT NULL, 236 | `encrypted_password` varchar(256) NOT NULL, 237 | `salt` varchar(10) NOT NULL, 238 | `created_at` datetime DEFAULT NULL 239 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 240 | 241 | -- 242 | -- Dumping data for table `student_users` 243 | -- 244 | 245 | INSERT INTO `student_users` (`_id`, `unique_id`, `name`, `student_id`, `email`, `encrypted_password`, `salt`, `created_at`) VALUES 246 | (1, '58efcae56c9470.34410783', 'JOHN DOE', 1, 'johndoe@johndoe.com', '$2y$10$MPrAg8l0yy5f0CVdasce5uKMGkyC5vXnngbNPOr.33uyNnzgOUBhS', '52b585a964', '2017-04-13 19:00:53'), 247 | (2, '58efcb5a559fd2.30550164', 'HARRY POTTER', 2, 'harrypotter@harrypotter.com', '$2y$10$noxZuxEGvO0be0MdFdSv8OPSFJRm/EyVx/f4.ubLhSTlAkZpEcZrG', '308d4cab2a', '2017-04-13 19:02:50'), 248 | (3, '58efcc919792f0.67099008', 'ROWAN ATKINSON', 3, 'rowanatkinson@rowanatkinson.com', '$2y$10$x.AxYRgQzzful.nmExU4wuy5AXR1DMaTTFOtbx1DYW2XqAzFTZYCu', '4ba1ae84f1', '2017-04-13 19:08:01'), 249 | (4, '58efccdedc3144.58297441', 'TONY STARK', 4, 'tonystark@tonystark.com', '$2y$10$0zp7rakUtqWaInyLhJbayeuNy5NBHQTRdYN87V/vQcykeCIgjyHXe', '0debd212ae', '2017-04-13 19:09:18'), 250 | (6, '58efcf0fdb88c6.75771560', 'TANIN ROJANAPIANSATITH', 4256422, 'eeytr1@nottingham.ac.uk', '$2y$10$Cb0JMNx5zM8WTWxR3TyLtuD3z7zy66ztSsag28WJ2YZcxARK4xkN6', '8bb7a88899', '2017-04-13 19:18:39'), 251 | (7, '58fa1f030d0ba8.65547168', 'WILSON', 5, 'wilson@wilson.com', '$2y$10$sTmavAYoQCKNI34EWBvwbOxwH7l/Pt5K0UPF3pzunkNY1MCnJAwDi', 'fcd30a93b0', '2017-04-21 15:02:27'), 252 | (8, '5900dda3a3bff6.78741164', 'no salt', 6, 'nosalt@nosalt.com', '$2y$10$TS5llQ9TH2bkzdv5q1693uRb/qfjzOFhRD8I0ehnyJi.YyCC9sooe', '9b4c5d4065', '2017-04-26 17:49:23'), 253 | (9, '5900de9b95c616.64264107', 'only hash, no salt', 7, 'onlyhash@nosalt.com', '$2y$10$NMm9Jti82VaIOiXGuT.mDuAoTCu8A9hWVrsiUPqIkCgiOQAOwc8fW', '51186d95fd', '2017-04-26 17:53:31'), 254 | (10, '5900df8d61ffe9.39094541', 'HASH WITH NO SALT', 8, 'hashwithnosalt@nosalt.com', '$2y$10$MRljBfiHeOAG2EmZzGCEB.fRjzhHEQo7toIR/E1cVo.x3m98FGedK', 'e69abe545d', '2017-04-26 17:57:33'), 255 | (11, '5900e00edc29e3.23316944', 'HASH WITH NO SALT2', 9, 'hashwithnosalt2@nosalt.com', '$2y$10$nkTfji9c4KddNAxh8brrneSeYADAb3Uid2VTs1iYpuoavyjPVaI2y', 'f9eb2f030b', '2017-04-26 17:59:42'), 256 | (12, '5900e046889487.52708045', 'HASH WITH SALT', 10, 'hashwithsalt@nosalt.com', '$2y$10$o08j4hI79pTDEOd6wFOtPutysCMSGNRdmrpNvRvglFapGUL5VXcZu', '08a48a2f86', '2017-04-26 18:00:38'), 257 | (13, '5900e4096eb659.05031566', 'no salt', 11, 'cryptnosalt@nosalt.com', '$1$80Dlr6Zx$V54s6AgYjHA5QU3BXvDkx0', 'f71e89d375', '2017-04-26 18:16:41'), 258 | (14, '5900e4d217e914.03976400', 'no salt', 12, 'md5nosalt@nosalt.com', '4f4e04a5f8ffded8609f0dd98c39ce3c', '607910b985', '2017-04-26 18:20:02'); 259 | 260 | -- 261 | -- Indexes for dumped tables 262 | -- 263 | 264 | -- 265 | -- Indexes for table `lecturerinfo` 266 | -- 267 | ALTER TABLE `lecturerinfo` 268 | ADD PRIMARY KEY (`_id`), 269 | ADD KEY `lecturerId` (`lecturerId`); 270 | 271 | -- 272 | -- Indexes for table `lecturermodule` 273 | -- 274 | ALTER TABLE `lecturermodule` 275 | ADD PRIMARY KEY (`_id`), 276 | ADD KEY `Lecturer_id` (`Lecturer_id`), 277 | ADD KEY `Module_id` (`Module_id`); 278 | 279 | -- 280 | -- Indexes for table `lecturer_users` 281 | -- 282 | ALTER TABLE `lecturer_users` 283 | ADD PRIMARY KEY (`_id`); 284 | 285 | -- 286 | -- Indexes for table `moduleinfo` 287 | -- 288 | ALTER TABLE `moduleinfo` 289 | ADD PRIMARY KEY (`_id`), 290 | ADD KEY `_id` (`_id`), 291 | ADD KEY `moduleId` (`moduleId`), 292 | ADD KEY `moduleId_2` (`moduleId`); 293 | 294 | -- 295 | -- Indexes for table `studentinfo` 296 | -- 297 | ALTER TABLE `studentinfo` 298 | ADD PRIMARY KEY (`_id`), 299 | ADD KEY `studentId` (`student_id`), 300 | ADD KEY `student_id` (`student_id`); 301 | 302 | -- 303 | -- Indexes for table `studentmodule` 304 | -- 305 | ALTER TABLE `studentmodule` 306 | ADD PRIMARY KEY (`_id`), 307 | ADD KEY `Student_id` (`Student_id`), 308 | ADD KEY `Module_id` (`Module_id`), 309 | ADD KEY `Module_id_2` (`Module_id`); 310 | 311 | -- 312 | -- Indexes for table `student_users` 313 | -- 314 | ALTER TABLE `student_users` 315 | ADD PRIMARY KEY (`_id`); 316 | 317 | -- 318 | -- AUTO_INCREMENT for dumped tables 319 | -- 320 | 321 | -- 322 | -- AUTO_INCREMENT for table `lecturerinfo` 323 | -- 324 | ALTER TABLE `lecturerinfo` 325 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; 326 | -- 327 | -- AUTO_INCREMENT for table `lecturermodule` 328 | -- 329 | ALTER TABLE `lecturermodule` 330 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; 331 | -- 332 | -- AUTO_INCREMENT for table `lecturer_users` 333 | -- 334 | ALTER TABLE `lecturer_users` 335 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; 336 | -- 337 | -- AUTO_INCREMENT for table `moduleinfo` 338 | -- 339 | ALTER TABLE `moduleinfo` 340 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33; 341 | -- 342 | -- AUTO_INCREMENT for table `studentinfo` 343 | -- 344 | ALTER TABLE `studentinfo` 345 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; 346 | -- 347 | -- AUTO_INCREMENT for table `studentmodule` 348 | -- 349 | ALTER TABLE `studentmodule` 350 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51; 351 | -- 352 | -- AUTO_INCREMENT for table `student_users` 353 | -- 354 | ALTER TABLE `student_users` 355 | MODIFY `_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; 356 | -- 357 | -- Constraints for dumped tables 358 | -- 359 | 360 | -- 361 | -- Constraints for table `lecturermodule` 362 | -- 363 | ALTER TABLE `lecturermodule` 364 | ADD CONSTRAINT `LM_lecturer_fk` FOREIGN KEY (`Lecturer_id`) REFERENCES `lecturerinfo` (`lecturerId`) ON DELETE NO ACTION ON UPDATE CASCADE, 365 | ADD CONSTRAINT `LM_module_fk` FOREIGN KEY (`Module_id`) REFERENCES `moduleinfo` (`moduleId`) ON DELETE NO ACTION ON UPDATE CASCADE; 366 | 367 | -- 368 | -- Constraints for table `studentmodule` 369 | -- 370 | ALTER TABLE `studentmodule` 371 | ADD CONSTRAINT `SM_module_fk` FOREIGN KEY (`Module_id`) REFERENCES `moduleinfo` (`moduleId`) ON DELETE NO ACTION ON UPDATE CASCADE, 372 | ADD CONSTRAINT `SM_student_fk` FOREIGN KEY (`Student_id`) REFERENCES `studentinfo` (`student_id`) ON DELETE NO ACTION ON UPDATE CASCADE; 373 | COMMIT; 374 | 375 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 376 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 377 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 378 | -------------------------------------------------------------------------------- /lecturerLogin/DBOperations.php: -------------------------------------------------------------------------------- 1 | conn = new PDO("mysql:host=".$this -> host.";dbname=".$this -> db, $this -> user, $this -> pass); 22 | 23 | } 24 | 25 | public function insertData($name,$lecturer_id,$email,$password){ 26 | 27 | $unique_id = uniqid('', true); 28 | $hash = $this->getHash($password); 29 | $encrypted_password = $hash["encrypted"]; 30 | $salt = $hash["salt"]; 31 | 32 | $sql = 'INSERT INTO lecturer_users SET unique_id =:unique_id,name =:name,lecturer_id =:lecturer_id, 33 | email =:email,encrypted_password =:encrypted_password,salt =:salt,created_at = NOW()'; 34 | 35 | $query = $this ->conn ->prepare($sql); 36 | $query->execute(array('unique_id' => $unique_id, ':name' => $name, ':lecturer_id' => $lecturer_id, ':email' => $email, 37 | ':encrypted_password' => $encrypted_password, ':salt' => $salt)); 38 | 39 | if ($query) { 40 | 41 | return true; 42 | 43 | } else { 44 | 45 | return false; 46 | 47 | } 48 | } 49 | 50 | public function checkLogin($email, $password) { 51 | 52 | $sql = 'SELECT * FROM lecturer_users WHERE email = :email'; 53 | $query = $this -> conn -> prepare($sql); 54 | $query -> execute(array(':email' => $email)); 55 | $data = $query -> fetchObject(); 56 | $salt = $data -> salt; 57 | $db_encrypted_password = $data -> encrypted_password; 58 | 59 | if ($this -> verifyHash($password.$salt,$db_encrypted_password) ) { 60 | 61 | $user["name"] = $data -> name; 62 | $user["lecturer_id"] = $data -> lecturer_id; 63 | $user["email"] = $data -> email; 64 | $user["unique_id"] = $data -> unique_id; 65 | return $user; 66 | 67 | } else { 68 | 69 | return false; 70 | } 71 | } 72 | 73 | public function changePassword($email, $password){ 74 | 75 | $hash = $this -> getHash($password); 76 | $encrypted_password = $hash["encrypted"]; 77 | $salt = $hash["salt"]; 78 | 79 | $sql = 'UPDATE lecturer_users SET encrypted_password = :encrypted_password, salt = :salt WHERE email = :email'; 80 | $query = $this -> conn -> prepare($sql); 81 | $query -> execute(array(':email' => $email, ':encrypted_password' => $encrypted_password, ':salt' => $salt)); 82 | 83 | if ($query) { 84 | 85 | return true; 86 | 87 | } else { 88 | 89 | return false; 90 | 91 | } 92 | } 93 | 94 | public function checkUserExist($email){ 95 | 96 | $sql = 'SELECT COUNT(*) from lecturer_users WHERE email =:email'; 97 | $query = $this -> conn -> prepare($sql); 98 | $query -> execute(array('email' => $email)); 99 | 100 | if($query){ 101 | 102 | $row_count = $query -> fetchColumn(); 103 | 104 | if ($row_count == 0){ 105 | 106 | return false; 107 | 108 | } else { 109 | 110 | return true; 111 | 112 | } 113 | } else { 114 | 115 | return false; 116 | } 117 | } 118 | 119 | public function getHash($password) { 120 | 121 | $salt = sha1(rand()); 122 | $salt = substr($salt, 0, 10); 123 | $encrypted = password_hash($password.$salt, PASSWORD_DEFAULT); 124 | $hash = array("salt" => $salt, "encrypted" => $encrypted); 125 | 126 | return $hash; 127 | 128 | } 129 | 130 | public function verifyHash($password, $hash) { 131 | 132 | return password_verify ($password, $hash); 133 | } 134 | } -------------------------------------------------------------------------------- /lecturerLogin/Functions.php: -------------------------------------------------------------------------------- 1 | db = new DBOperations(); 18 | 19 | } 20 | 21 | public function registerUser($name, $lecturer_id, $email, $password) { 22 | 23 | $db = $this -> db; 24 | 25 | if (!empty($name) && !empty($lecturer_id) && !empty($email) && !empty($password)) { 26 | 27 | if ($db -> checkUserExist($email)) { 28 | 29 | $response["result"] = "failure"; 30 | $response["message"] = "User Already Registered !"; 31 | return json_encode($response); 32 | 33 | } else { 34 | 35 | $result = $db -> insertData($name, $lecturer_id, $email, $password); 36 | 37 | if ($result) { 38 | 39 | $response["result"] = "success"; 40 | $response["message"] = "User Registered Successfully !"; 41 | return json_encode($response); 42 | 43 | } else { 44 | 45 | $response["result"] = "failure"; 46 | $response["message"] = "Registration Failure"; 47 | return json_encode($response); 48 | 49 | } 50 | } 51 | } else { 52 | 53 | return $this -> getMsgParamNotEmpty(); 54 | 55 | } 56 | } 57 | 58 | public function loginUser($email, $password) { 59 | 60 | $db = $this -> db; 61 | 62 | if (!empty($email) && !empty($password)) { 63 | 64 | if ($db -> checkUserExist($email)) { 65 | 66 | $result = $db -> checkLogin($email, $password); 67 | 68 | if(!$result) { 69 | 70 | $response["result"] = "failure"; 71 | $response["message"] = "Invaild Email or Password"; 72 | return json_encode($response); 73 | 74 | } else { 75 | 76 | $response["result"] = "success"; 77 | $response["message"] = "Login Sucessful"; 78 | $response["user"] = $result; 79 | return json_encode($response); 80 | 81 | } 82 | } else { 83 | 84 | $response["result"] = "failure"; 85 | $response["message"] = "Invaild Email or Password"; 86 | return json_encode($response); 87 | 88 | } 89 | } else { 90 | 91 | return $this -> getMsgParamNotEmpty(); 92 | } 93 | } 94 | 95 | public function changePassword($email, $old_password, $new_password) { 96 | 97 | $db = $this -> db; 98 | 99 | if (!empty($email) && !empty($old_password) && !empty($new_password)) { 100 | 101 | if(!$db -> checkLogin($email, $old_password)){ 102 | 103 | $response["result"] = "failure"; 104 | $response["message"] = 'Invalid Old Password'; 105 | return json_encode($response); 106 | 107 | } else { 108 | 109 | $result = $db -> changePassword($email, $new_password); 110 | 111 | if($result) { 112 | 113 | $response["result"] = "success"; 114 | $response["message"] = "Password Changed Successfully"; 115 | return json_encode($response); 116 | 117 | } else { 118 | 119 | $response["result"] = "failure"; 120 | $response["message"] = 'Error Updating Password'; 121 | return json_encode($response); 122 | 123 | } 124 | } 125 | } else { 126 | 127 | return $this -> getMsgParamNotEmpty(); 128 | } 129 | } 130 | 131 | public function isEmailValid($email){ 132 | 133 | return filter_var($email, FILTER_VALIDATE_EMAIL); 134 | } 135 | 136 | public function getMsgParamNotEmpty(){ 137 | 138 | $response["result"] = "failure"; 139 | $response["message"] = "Parameters should not be empty !"; 140 | return json_encode($response); 141 | 142 | } 143 | 144 | public function getMsgInvalidParam(){ 145 | 146 | $response["result"] = "failure"; 147 | $response["message"] = "Invalid Parameters"; 148 | return json_encode($response); 149 | 150 | } 151 | 152 | public function getMsgInvalidEmail(){ 153 | 154 | $response["result"] = "failure"; 155 | $response["message"] = "Invalid Email or Password"; 156 | return json_encode($response); 157 | 158 | } 159 | } -------------------------------------------------------------------------------- /lecturerLogin/index.php: -------------------------------------------------------------------------------- 1 | operation)){ 19 | if(isset($_POST['tag']) && $_POST['tag'] != ''){ 20 | 21 | // $operation = $data -> operation; 22 | $tag = $_POST['tag']; 23 | 24 | if($tag == 'register'){ 25 | 26 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> name) 27 | // && isset($data -> user -> student_id) 28 | // && isset($data -> user -> email) && isset($data -> user -> password)){ 29 | if (isset($_POST['name']) && $_POST['name'] != '' 30 | && isset($_POST['email']) && $_POST['email'] != '' 31 | && isset($_POST['lecturer_id']) && $_POST['lecturer_id'] != '' 32 | && isset($_POST['password']) && $_POST['password'] != '') { 33 | 34 | 35 | // $user = $data -> user; 36 | // $name = $user -> name; 37 | // $student_id = $user -> student_id; 38 | // $email = $user -> email; 39 | // $password = $user -> password; 40 | 41 | $name = $_POST['name']; 42 | $email = $_POST['email']; 43 | $lecturer_id = $_POST['lecturer_id']; 44 | $password = $_POST['password']; 45 | 46 | 47 | if ($fun -> isEmailValid($email)) { 48 | 49 | echo $fun -> registerUser($name, $lecturer_id, $email, $password); 50 | 51 | } else { 52 | 53 | echo $fun -> getMsgInvalidEmail(); 54 | } 55 | 56 | } else { 57 | 58 | echo $fun -> getMsgInvalidParam(); 59 | 60 | } 61 | 62 | // }else if ($operation == 'login') { 63 | }else if ($tag == 'login') { 64 | 65 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> email) && isset($data -> user -> password)){ 66 | if (isset($_POST['email']) && $_POST['email'] != '' 67 | && isset($_POST['password']) && $_POST['password'] != '') { 68 | 69 | // $user = $data -> user; 70 | // $email = $user -> email; 71 | // $password = $user -> password; 72 | $email = $_POST['email']; 73 | $password = $_POST['password']; 74 | 75 | echo $fun -> loginUser($email, $password); 76 | 77 | } else { 78 | 79 | echo $fun -> getMsgInvalidParam(); 80 | 81 | } 82 | // } else if ($operation == 'chgPass') { 83 | } else if ($tag == 'chgPass') { 84 | 85 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> email) && isset($data -> user -> old_password) 86 | // && isset($data -> user -> new_password)){ 87 | if (isset($_POST['old_password']) && $_POST['old_password'] != '' 88 | && isset($_POST['email']) && $_POST['email'] != '' 89 | && isset($_POST['new_password']) && $_POST['new_password'] != '') { 90 | 91 | // $user = $data -> user; 92 | // $email = $user -> email; 93 | // $old_password = $user -> old_password; 94 | // $new_password = $user -> new_password; 95 | 96 | $email = $_POST['email']; 97 | $old_password = $_POST['old_password']; 98 | $new_password = $_POST['new_password']; 99 | 100 | echo $fun -> changePassword($email, $old_password, $new_password); 101 | 102 | } else { 103 | 104 | echo $fun -> getMsgInvalidParam(); 105 | 106 | } 107 | } 108 | 109 | } else { 110 | 111 | echo $fun -> getMsgInvalidParam(); 112 | 113 | } 114 | } else if ($_SERVER['REQUEST_METHOD'] == 'GET'){ 115 | 116 | echo "UoN Attendance Monitoring Login API"; 117 | 118 | } -------------------------------------------------------------------------------- /lecturerModuleGet.php: -------------------------------------------------------------------------------- 1 | getConnection(); 13 | 14 | $sqlStmt = "SELECT * FROM `ModuleInfo` WHERE moduleId IN (SELECT Module_id FROM `lecturermodule` "; 15 | 16 | //------------------------------------------------------------------------ 17 | //if (isset($_GET["id"], $_GET["name"])) { 18 | //// $sqlStmt .= " WHERE _id = " . $_GET["id"] . ";"; 19 | //// $name = mysqli_real_escape_string($_GET["name"],""); 20 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] . " OR name = '" . $_GET["name"] . "';"; 21 | // 22 | // // 23 | // //var_dump($sqlStmt); 24 | // 25 | //} 26 | //if (isset($_GET["id"], $_GET["id2"], $_GET["id3"], $_GET["id4"])) { 27 | // 28 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 29 | // . " OR _id = " . $_GET["id2"] 30 | // . " OR _id = " . $_GET["id3"] 31 | // . " OR _id = " . $_GET["id4"] . ";"; 32 | // //var_dump($sqlStmt); 33 | // 34 | //} 35 | //elseif (isset($_GET["id"], $_GET["id2"], $_GET["id3"])) { 36 | // 37 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 38 | // . " OR _id = " . $_GET["id2"] 39 | // . " OR _id = " . $_GET["id3"] . ";"; 40 | //// var_dump($sqlStmt); 41 | // 42 | //} 43 | //elseif (isset($_GET["id"], $_GET["id2"])) { 44 | // 45 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 46 | // . " OR _id = " . $_GET["id2"] . ";"; 47 | // //var_dump($sqlStmt); 48 | // 49 | //} 50 | 51 | 52 | 53 | if (isset($_GET["lecturer_id"])) { 54 | 55 | $sqlStmt .= " WHERE Lecturer_id = " . $_GET["lecturer_id"] . ");"; 56 | // var_dump($sqlStmt); 57 | 58 | 59 | // echo $sqlStmt; 60 | } else { 61 | $sqlStmt .= ");"; 62 | } 63 | 64 | 65 | // debugging 66 | //echo $_GET["student_id"]; 67 | ////echo trim($_GET["name"]); 68 | //echo trim($_GET["id2"]); 69 | 70 | 71 | $results = $db->unsafeQueryExec($sqlStmt); 72 | 73 | //var_dump($results); 74 | 75 | $allResults = []; 76 | 77 | 78 | while ($row = $results->fetch_assoc()) { 79 | array_push($allResults, $row); 80 | } 81 | 82 | //------------------------------------------------------------------------ 83 | 84 | //if (isset($_GET["id"])) { 85 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] . ";"; 86 | //// $sqlStmt = "SELECT * FROM `StudentInfo` WHERE _id IN(`". $_GET["id"] . "`,`" . $_GET["id2"] . "`);"; 87 | // 88 | //} 89 | // 90 | //$results = $db->unsafeQueryExec($sqlStmt); 91 | // 92 | // 93 | //while ($row = $results->fetch_assoc()) { 94 | // array_push($allResults, $row); 95 | //} 96 | 97 | 98 | // make object 99 | $content['modules']=$allResults; 100 | //$content[$_POST['bla2']]=$allResults; // experiment works! 101 | echo json_encode($content); 102 | //echo $_POST["bla"]; 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /lecturerStatusClear.php: -------------------------------------------------------------------------------- 1 | connect_error){ 20 | die("Connecction failed: " . $conn->connect_error); 21 | } 22 | 23 | 24 | echo "Connected successfully"."
"; 25 | 26 | if(isset($_POST['status']) && $_POST['status'] != '' 27 | && isset($_POST['module_id']) && $_POST['module_id'] != ''){ 28 | 29 | $status = $_POST['status']; // String - checked, late, and absent 30 | $module_id = $_POST['module_id']; // String 31 | $sql = "UPDATE studentmodule SET status = '$status' WHERE Module_id = '$module_id'"; 32 | $sql2 = "UPDATE studentinfo SET AttendanceStatus = '$status' WHERE Student_id IN (SELECT Student_id FROM `StudentModule` WHERE Module_id = '$module_id')"; 33 | 34 | }else{ 35 | 36 | echo "invalid input"; 37 | 38 | } 39 | 40 | //$db->QueryExec($sql); 41 | 42 | 43 | if (($conn->query($sql) === TRUE) && ($conn->query($sql2) === TRUE)) { 44 | echo "Record updated successfully"; 45 | } else { 46 | echo "Error updating record: " . $conn->error; 47 | } 48 | // ------------------------------------------------------------------------------------- 49 | 50 | 51 | // close the connection 52 | $conn->close(); 53 | 54 | ?> 55 | -------------------------------------------------------------------------------- /studentAttendanceGet.php: -------------------------------------------------------------------------------- 1 | getConnection(); 12 | $sqlStmt = "SELECT * FROM `studentinfo` WHERE Student_id IN (SELECT Student_id FROM `StudentModule` "; 13 | 14 | if (isset($_GET["module_id"])) { 15 | 16 | $sqlStmt .= " WHERE Module_id = '" . $_GET["module_id"] . "');"; 17 | 18 | } else { 19 | $sqlStmt .= ");"; 20 | } 21 | 22 | 23 | $results = $db->unsafeQueryExec($sqlStmt); 24 | $allResults = []; 25 | 26 | while ($row = $results->fetch_assoc()) { 27 | array_push($allResults, $row); 28 | } 29 | 30 | $content['students']=$allResults; 31 | 32 | echo json_encode($content); 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /studentLogin/DBOperations.php: -------------------------------------------------------------------------------- 1 | conn = new PDO("mysql:host=".$this -> host.";dbname=".$this -> db, $this -> user, $this -> pass); 22 | 23 | } 24 | 25 | public function insertData($name,$student_id,$email,$password){ 26 | 27 | $unique_id = uniqid('', true); 28 | $hash = $this->getHash($password); 29 | $encrypted_password = $hash["encrypted"]; 30 | $salt = $hash["salt"]; 31 | 32 | $sql = 'INSERT INTO student_users SET unique_id =:unique_id,name =:name,student_id =:student_id, 33 | email =:email,encrypted_password =:encrypted_password,salt =:salt,created_at = NOW()'; 34 | 35 | $query = $this ->conn ->prepare($sql); 36 | $query->execute(array('unique_id' => $unique_id, ':name' => $name, ':student_id' => $student_id, ':email' => $email, 37 | ':encrypted_password' => $encrypted_password, ':salt' => $salt)); 38 | 39 | if ($query) { 40 | 41 | return true; 42 | 43 | } else { 44 | 45 | return false; 46 | 47 | } 48 | } 49 | 50 | public function checkLogin($email, $password) { 51 | 52 | $sql = 'SELECT * FROM student_users WHERE email = :email'; 53 | $query = $this -> conn -> prepare($sql); 54 | $query -> execute(array(':email' => $email)); 55 | $data = $query -> fetchObject(); 56 | $salt = $data -> salt; 57 | $db_encrypted_password = $data -> encrypted_password; 58 | 59 | if ($this -> verifyHash($password.$salt,$db_encrypted_password) ) { 60 | 61 | $user["name"] = $data -> name; 62 | $user["student_id"] = $data -> student_id; 63 | $user["email"] = $data -> email; 64 | $user["unique_id"] = $data -> unique_id; 65 | return $user; 66 | 67 | } else { 68 | 69 | return false; 70 | } 71 | } 72 | 73 | public function changePassword($email, $password){ 74 | 75 | $hash = $this -> getHash($password); 76 | $encrypted_password = $hash["encrypted"]; 77 | $salt = $hash["salt"]; 78 | 79 | $sql = 'UPDATE student_users SET encrypted_password = :encrypted_password, salt = :salt WHERE email = :email'; 80 | $query = $this -> conn -> prepare($sql); 81 | $query -> execute(array(':email' => $email, ':encrypted_password' => $encrypted_password, ':salt' => $salt)); 82 | 83 | if ($query) { 84 | 85 | return true; 86 | 87 | } else { 88 | 89 | return false; 90 | 91 | } 92 | } 93 | 94 | public function checkUserExist($email){ 95 | 96 | $sql = 'SELECT COUNT(*) from student_users WHERE email =:email'; 97 | $query = $this -> conn -> prepare($sql); 98 | $query -> execute(array('email' => $email)); 99 | 100 | if($query){ 101 | 102 | $row_count = $query -> fetchColumn(); 103 | 104 | if ($row_count == 0){ 105 | 106 | return false; 107 | 108 | } else { 109 | 110 | return true; 111 | 112 | } 113 | } else { 114 | 115 | return false; 116 | } 117 | } 118 | 119 | public function getHash($password) { 120 | 121 | $salt = sha1(rand()); 122 | $salt = substr($salt, 0, 10); 123 | $encrypted = password_hash($password.$salt, PASSWORD_DEFAULT); 124 | 125 | // no salt 126 | // $encrypted = md5($password); 127 | $hash = array("salt" => $salt, "encrypted" => $encrypted); 128 | 129 | return $hash; 130 | 131 | } 132 | 133 | public function verifyHash($password, $hash) { 134 | 135 | return password_verify ($password, $hash); 136 | } 137 | } -------------------------------------------------------------------------------- /studentLogin/Functions.php: -------------------------------------------------------------------------------- 1 | db = new DBOperations(); 18 | 19 | } 20 | 21 | public function registerUser($name, $student_id, $email, $password) { 22 | 23 | $db = $this -> db; 24 | 25 | if (!empty($name) && !empty($student_id) && !empty($email) && !empty($password)) { 26 | 27 | if ($db -> checkUserExist($email)) { 28 | 29 | $response["result"] = "failure"; 30 | $response["message"] = "User Already Registered !"; 31 | return json_encode($response); 32 | 33 | } else { 34 | 35 | $result = $db -> insertData($name, $student_id, $email, $password); 36 | 37 | if ($result) { 38 | 39 | $response["result"] = "success"; 40 | $response["message"] = "User Registered Successfully !"; 41 | return json_encode($response); 42 | 43 | } else { 44 | 45 | $response["result"] = "failure"; 46 | $response["message"] = "Registration Failure"; 47 | return json_encode($response); 48 | 49 | } 50 | } 51 | } else { 52 | 53 | return $this -> getMsgParamNotEmpty(); 54 | 55 | } 56 | } 57 | 58 | public function loginUser($email, $password) { 59 | 60 | $db = $this -> db; 61 | 62 | if (!empty($email) && !empty($password)) { 63 | 64 | if ($db -> checkUserExist($email)) { 65 | 66 | $result = $db -> checkLogin($email, $password); 67 | 68 | if(!$result) { 69 | 70 | $response["result"] = "failure"; 71 | $response["message"] = "Invaild Email of Password"; 72 | return json_encode($response); 73 | 74 | } else { 75 | 76 | $response["result"] = "success"; 77 | $response["message"] = "Login Sucessful"; 78 | $response["user"] = $result; 79 | return json_encode($response); 80 | 81 | } 82 | 83 | } else { 84 | 85 | $response["result"] = "failure"; 86 | $response["message"] = "Invaild Email or Password"; 87 | return json_encode($response); 88 | 89 | } 90 | } else { 91 | 92 | return $this -> getMsgParamNotEmpty(); 93 | } 94 | } 95 | 96 | public function changePassword($email, $old_password, $new_password) { 97 | 98 | $db = $this -> db; 99 | 100 | if (!empty($email) && !empty($old_password) && !empty($new_password)) { 101 | 102 | if(!$db -> checkLogin($email, $old_password)){ 103 | 104 | $response["result"] = "failure"; 105 | $response["message"] = 'Invalid Old Password'; 106 | return json_encode($response); 107 | 108 | } else { 109 | 110 | $result = $db -> changePassword($email, $new_password); 111 | 112 | if($result) { 113 | 114 | $response["result"] = "success"; 115 | $response["message"] = "Password Changed Successfully"; 116 | return json_encode($response); 117 | 118 | } else { 119 | 120 | $response["result"] = "failure"; 121 | $response["message"] = 'Error Updating Password'; 122 | return json_encode($response); 123 | 124 | } 125 | } 126 | } else { 127 | 128 | return $this -> getMsgParamNotEmpty(); 129 | } 130 | } 131 | 132 | public function isEmailValid($email){ 133 | 134 | return filter_var($email, FILTER_VALIDATE_EMAIL); 135 | } 136 | 137 | public function getMsgParamNotEmpty(){ 138 | 139 | $response["result"] = "failure"; 140 | $response["message"] = "Parameters should not be empty !"; 141 | return json_encode($response); 142 | 143 | } 144 | 145 | public function getMsgInvalidParam(){ 146 | 147 | $response["result"] = "failure"; 148 | $response["message"] = "Invalid Parameters"; 149 | return json_encode($response); 150 | 151 | } 152 | 153 | public function getMsgInvalidEmail(){ 154 | 155 | $response["result"] = "failure"; 156 | $response["message"] = "Invalid Email or Password"; 157 | return json_encode($response); 158 | 159 | } 160 | } -------------------------------------------------------------------------------- /studentLogin/index.php: -------------------------------------------------------------------------------- 1 | operation)){ 19 | if(isset($_POST['tag']) && $_POST['tag'] != ''){ 20 | 21 | // $operation = $data -> operation; 22 | $tag = $_POST['tag']; 23 | 24 | if($tag == 'register'){ 25 | 26 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> name) 27 | // && isset($data -> user -> student_id) 28 | // && isset($data -> user -> email) && isset($data -> user -> password)){ 29 | if (isset($_POST['name']) && $_POST['name'] != '' 30 | && isset($_POST['email']) && $_POST['email'] != '' 31 | && isset($_POST['student_id']) && $_POST['student_id'] != '' 32 | && isset($_POST['password']) && $_POST['password'] != '') { 33 | 34 | 35 | // $user = $data -> user; 36 | // $name = $user -> name; 37 | // $student_id = $user -> student_id; 38 | // $email = $user -> email; 39 | // $password = $user -> password; 40 | 41 | $name = $_POST['name']; 42 | $email = $_POST['email']; 43 | $student_id = $_POST['student_id']; 44 | $password = $_POST['password']; 45 | 46 | 47 | if ($fun -> isEmailValid($email)) { 48 | 49 | echo $fun -> registerUser($name, $student_id, $email, $password); 50 | 51 | } else { 52 | 53 | echo $fun -> getMsgInvalidEmail(); 54 | } 55 | 56 | } else { 57 | 58 | echo $fun -> getMsgInvalidParam(); 59 | 60 | } 61 | 62 | // }else if ($operation == 'login') { 63 | }else if ($tag == 'login') { 64 | 65 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> email) && isset($data -> user -> password)){ 66 | if (isset($_POST['email']) && $_POST['email'] != '' 67 | && isset($_POST['password']) && $_POST['password'] != '') { 68 | 69 | // $user = $data -> user; 70 | // $email = $user -> email; 71 | // $password = $user -> password; 72 | $email = $_POST['email']; 73 | $password = $_POST['password']; 74 | 75 | echo $fun -> loginUser($email, $password); 76 | 77 | } else { 78 | 79 | echo $fun -> getMsgInvalidParam(); 80 | 81 | } 82 | // } else if ($operation == 'chgPass') { 83 | } else if ($tag == 'chgPass') { 84 | 85 | // if(isset($data -> user ) && !empty($data -> user) && isset($data -> user -> email) && isset($data -> user -> old_password) 86 | // && isset($data -> user -> new_password)){ 87 | if (isset($_POST['old_password']) && $_POST['old_password'] != '' 88 | && isset($_POST['email']) && $_POST['email'] != '' 89 | && isset($_POST['new_password']) && $_POST['new_password'] != '') { 90 | 91 | // $user = $data -> user; 92 | // $email = $user -> email; 93 | // $old_password = $user -> old_password; 94 | // $new_password = $user -> new_password; 95 | 96 | $email = $_POST['email']; 97 | $old_password = $_POST['old_password']; 98 | $new_password = $_POST['new_password']; 99 | 100 | echo $fun -> changePassword($email, $old_password, $new_password); 101 | 102 | } else { 103 | 104 | echo $fun -> getMsgInvalidParam(); 105 | 106 | } 107 | } 108 | 109 | } else { 110 | 111 | echo $fun -> getMsgInvalidParam(); 112 | 113 | } 114 | } else if ($_SERVER['REQUEST_METHOD'] == 'GET'){ 115 | 116 | echo "UoN CheckIn Login API"; 117 | 118 | } -------------------------------------------------------------------------------- /studentModuleGet.php: -------------------------------------------------------------------------------- 1 | getConnection(); 13 | 14 | $sqlStmt = "SELECT * FROM `ModuleInfo` WHERE moduleId IN (SELECT Module_id FROM `StudentModule` "; 15 | 16 | //------------------------------------------------------------------------ 17 | //if (isset($_GET["id"], $_GET["name"])) { 18 | //// $sqlStmt .= " WHERE _id = " . $_GET["id"] . ";"; 19 | //// $name = mysqli_real_escape_string($_GET["name"],""); 20 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] . " OR name = '" . $_GET["name"] . "';"; 21 | // 22 | // // 23 | // //var_dump($sqlStmt); 24 | // 25 | //} 26 | //if (isset($_GET["id"], $_GET["id2"], $_GET["id3"], $_GET["id4"])) { 27 | // 28 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 29 | // . " OR _id = " . $_GET["id2"] 30 | // . " OR _id = " . $_GET["id3"] 31 | // . " OR _id = " . $_GET["id4"] . ";"; 32 | // //var_dump($sqlStmt); 33 | // 34 | //} 35 | //elseif (isset($_GET["id"], $_GET["id2"], $_GET["id3"])) { 36 | // 37 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 38 | // . " OR _id = " . $_GET["id2"] 39 | // . " OR _id = " . $_GET["id3"] . ";"; 40 | //// var_dump($sqlStmt); 41 | // 42 | //} 43 | //elseif (isset($_GET["id"], $_GET["id2"])) { 44 | // 45 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] 46 | // . " OR _id = " . $_GET["id2"] . ";"; 47 | // //var_dump($sqlStmt); 48 | // 49 | //} 50 | 51 | if (isset($_GET["student_id"])) { 52 | 53 | $sqlStmt .= " WHERE Student_id = " . $_GET["student_id"] . ");"; 54 | // var_dump($sqlStmt); 55 | 56 | 57 | // echo $sqlStmt; 58 | } else { 59 | $sqlStmt .= ");"; 60 | } 61 | 62 | 63 | // debugging 64 | //echo $_GET["student_id"]; 65 | ////echo trim($_GET["name"]); 66 | //echo trim($_GET["id2"]); 67 | 68 | 69 | $results = $db->unsafeQueryExec($sqlStmt); 70 | 71 | //var_dump($results); 72 | 73 | $allResults = []; 74 | 75 | 76 | while ($row = $results->fetch_assoc()) { 77 | array_push($allResults, $row); 78 | } 79 | 80 | //------------------------------------------------------------------------ 81 | 82 | //if (isset($_GET["id"])) { 83 | // $sqlStmt .= " WHERE _id = " . $_GET["id"] . ";"; 84 | //// $sqlStmt = "SELECT * FROM `StudentInfo` WHERE _id IN(`". $_GET["id"] . "`,`" . $_GET["id2"] . "`);"; 85 | // 86 | //} 87 | // 88 | //$results = $db->unsafeQueryExec($sqlStmt); 89 | // 90 | // 91 | //while ($row = $results->fetch_assoc()) { 92 | // array_push($allResults, $row); 93 | //} 94 | 95 | 96 | // make object 97 | $content['modules']=$allResults; 98 | //$content[$_POST['bla2']]=$allResults; // experiment works! 99 | echo json_encode($content); 100 | //echo $_POST["bla"]; 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /studentModuleUpdate.php: -------------------------------------------------------------------------------- 1 | connect_error){ 20 | die("Connecction failed: " . $conn->connect_error); 21 | } 22 | 23 | 24 | echo "Connected successfully"."
"; 25 | 26 | if(isset($_POST['status']) && $_POST['status'] != '' 27 | && isset($_POST['student_id']) && $_POST['student_id'] != '' 28 | && isset($_POST['module_id']) && $_POST['module_id'] != ''){ 29 | 30 | $status = $_POST['status']; // String - checked, late, and absent 31 | $student_id = $_POST['student_id']; // integer 32 | $module_id = $_POST['module_id']; // String 33 | $sql = "UPDATE studentmodule SET status = '$status' WHERE Student_id = $student_id AND Module_id = '$module_id'"; 34 | $sql2 = "UPDATE studentinfo SET AttendanceStatus = '$status' WHERE Student_id IN (SELECT Student_id FROM `StudentModule` WHERE Module_id = '$module_id' AND student_id = '$student_id')"; 35 | // SELECT * FROM `studentinfo` WHERE Student_id IN (SELECT Student_id FROM `StudentModule` WHERE (status = 'checked' AND Module_id = 'MA0001') OR (status = 'late' AND Module_id = 'MA0001')) 36 | 37 | }else{ 38 | 39 | echo "invalid input"; 40 | 41 | } 42 | 43 | //$db->QueryExec($sql); 44 | 45 | if (($conn->query($sql) === TRUE) && ($conn->query($sql2) === TRUE)) { 46 | echo "Record updated successfully"; 47 | } else { 48 | echo "Error updating record: " . $conn->error; 49 | } 50 | // ------------------------------------------------------------------------------------- 51 | 52 | 53 | // close the connection 54 | $conn->close(); 55 | 56 | ?> 57 | -------------------------------------------------------------------------------- /studentStatusGet.php: -------------------------------------------------------------------------------- 1 | getConnection(); 12 | $sqlStmt = "SELECT * FROM `studentinfo` WHERE Student_id IN (SELECT Student_id FROM `StudentModule` "; 13 | 14 | if (isset($_GET["module_id"])) { 15 | 16 | $sqlStmt .= " WHERE (status = 'checked' AND Module_id = '" . $_GET["module_id"] . "') OR (status = 'late' AND Module_id = '" . $_GET["module_id"] . "'));"; 17 | 18 | // SELECT * FROM `studentinfo` WHERE Student_id IN (SELECT Student_id FROM `StudentModule` WHERE (status = 'checked' AND Module_id = 'MA0001') OR (status = 'late' AND Module_id = 'MA0001')) 19 | 20 | } else { 21 | $sqlStmt .= ");"; 22 | } 23 | 24 | 25 | $results = $db->unsafeQueryExec($sqlStmt); 26 | $allResults = []; 27 | 28 | while ($row = $results->fetch_assoc()) { 29 | array_push($allResults, $row); 30 | } 31 | 32 | $content['students_status']=$allResults; 33 | 34 | echo json_encode($content); 35 | 36 | 37 | 38 | 39 | 40 | --------------------------------------------------------------------------------