-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelayDemoStart.php
More file actions
55 lines (43 loc) · 1.49 KB
/
relayDemoStart.php
File metadata and controls
55 lines (43 loc) · 1.49 KB
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
<?php
header("Content-type:application/json");
$_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded";
error_reporting (E_ALL ^ E_WARNING && E_NOTICE);
//Response class
class DemoStartResponse {
var $successful;
function __construct () {
$this->successful = false;
}
}
//Connection properties
$servername = "localhost";
$username = "root";
$password = "admin";
//Create connection
$conn = new mysqli($servername, $username, $password);
//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//Extract data from POST
$roomID = $_POST["roomID"];
$courseID = $_POST["courseID"];
$relayUsed = $_POST["relayUsed"];
$slot = $_POST["slot"];
$attendance = $_POST["attendance"];
//Run query for inserting values to room status table for demo
$demoPreStartQuery = "TRUNCATE db_classroom_management.tbl_room_status";
$demoPreStartQueryReult = mysqli_query($conn, $demoPreStartQuery);
$demoStartQuery = "INSERT INTO db_classroom_management.tbl_room_status values (".$roomID.",".$courseID.",".$relayUsed.",".$attendance.",curdate(),". $slot.")";
$demoStartQueryResult = mysqli_query($conn, $demoStartQuery);
//Handle inserting values to room status table for demo response
$numberOfRows = mysqli_num_rows($demoStartQueryResult);
$response = new DemoStartResponse();
//Check if query worked properly
if ($demoStartQueryResult == true) {
$response->successful = true;
} else {
$response->roomIsActive = false;
}
echo json_encode($response);
?>