-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasynchronously.php
81 lines (74 loc) · 3.05 KB
/
asynchronously.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
<?php
include_once "includes/dbconnection.php";
$response = array();
// Update time on database every min if a post request of min and reg. no. is sent
if(isset($_POST["mins"]) && isset($_POST["registration_no"])){
$mins = $_POST["mins"];
$registration_no = $_POST["registration_no"];
$sql = "UPDATE candidates SET time_available='$mins' WHERE candidates_registration_no = '$registration_no'";
if(mysqli_query($conn, $sql)){
$response['error'] = false;
$response['message'] = "Time Updated Successfully";
}else{
$response['error'] = true;
$response['message'] = "Time Update Failed";
}
echo json_encode($response);
}
// Update answered options for course 1
if(isset($_POST["options"]) && isset($_POST["registration_no"]) && isset($_POST["course1"])){
$options = $_POST["options"];
$registration_no = $_POST["registration_no"];
$sql = "UPDATE candidates SET course1_score='$options' WHERE candidates_registration_no = '$registration_no'";
if(mysqli_query($conn, $sql)){
$response['error'] = false;
$response['message'] = "Scores Updated Successfully";
}else{
$response['error'] = true;
$response['message'] = "Scores Update Failed";
}
echo json_encode($response);
}
// Update answered options for course 2
if(isset($_POST["options"]) && isset($_POST["registration_no"]) && isset($_POST["course2"])){
$options = $_POST["options"];
$registration_no = $_POST["registration_no"];
$sql = "UPDATE candidates SET course2_score='$options' WHERE candidates_registration_no = '$registration_no'";
if(mysqli_query($conn, $sql)){
$response['error'] = false;
$response['message'] = "Scores Updated Successfully";
}else{
$response['error'] = true;
$response['message'] = "Scores Update Failed";
}
echo json_encode($response);
}
// Update answered options for course 3
if(isset($_POST["options"]) && isset($_POST["registration_no"]) && isset($_POST["course3"])){
$options = $_POST["options"];
$registration_no = $_POST["registration_no"];
$sql = "UPDATE candidates SET course3_score='$options' WHERE candidates_registration_no = '$registration_no'";
if(mysqli_query($conn, $sql)){
$response['error'] = false;
$response['message'] = "Scores Updated Successfully";
}else{
$response['error'] = true;
$response['message'] = "Scores Update Failed";
}
echo json_encode($response);
}
// Update answered options for course 4
if(isset($_POST["options"]) && isset($_POST["registration_no"]) && isset($_POST["course4"])){
$options = $_POST["options"];
$registration_no = $_POST["registration_no"];
$sql = "UPDATE candidates SET course4_score='$options' WHERE candidates_registration_no = '$registration_no'";
if(mysqli_query($conn, $sql)){
$response['error'] = false;
$response['message'] = "Scores Updated Successfully";
}else{
$response['error'] = true;
$response['message'] = "Scores Update Failed";
}
echo json_encode($response);
}
?>