-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoventryActions.php
More file actions
executable file
·38 lines (32 loc) · 972 Bytes
/
CoventryActions.php
File metadata and controls
executable file
·38 lines (32 loc) · 972 Bytes
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
<?php
header('Content-Type: application/json');
require __DIR__ . '/Credentials.php';
// Preallocate the Result
$Result = array();
// Connect to the database
$Conn = new mysqli($Servername, $Username, $Password, $Dbname);
if ($Conn->connect_error) {
die("Database connection failed: " . $Conn->connect_error);
}
// Get the inputs
$Input = json_decode(file_get_contents('php://input'), true);
$SubjectId = $Input['SubjectId'];
$SubjectId = mysqli_real_escape_string($Conn, $SubjectId);
// Get the State
$Sql = "SELECT * FROM Register WHERE SubjectId = '$SubjectId'";
$QueryRes = mysqli_query($Conn, $Sql);
if ($QueryRes === false) {
die("Sql failed to execute successfully!");
} else {
while ($Row = mysqli_fetch_assoc($QueryRes)) {
$State = $Row["State"];
}
}
// Set the Result
if ($State >= 0) {
$State = null;
}
$Result['State'] = $State;
// Close the database connection and return the Result
$Conn->close();
echo json_encode($Result);