This repository was archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmitIdrReview.php
More file actions
57 lines (55 loc) · 2.14 KB
/
submitIdrReview.php
File metadata and controls
57 lines (55 loc) · 2.14 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
56
57
<?php
include('SQLFunctions.php');
session_start();
$timestamp = date('Y-m-d H:i:s');
$link = f_sqlConnect();
if ($idrID = intval($_POST['idrID'])) {
if ($_POST['approve'] === 'true') {
if ($userID = intval($_POST['userID'])) {
if ($comment = $link->escape_string($_POST['comment'])) {
$commentQry = "INSERT idrComments (userID, comment, idrID, commentDate)
VALUES ('{$_POST['userID']}', '{$_POST['comment']}', {$idrID}, '{$timestamp}')";
$result = $link->query($commentQry);
if (!result) {
http_response_code(500);
$code = http_response_code();
echo "There was a problem adding your comment";
return;
}
}
$idrQry = "UPDATE IDR SET approvedBy='{$userID}' where idrID={$idrID}";
$result = $link->query($idrQry);
if (!$result) {
http_response_code(500);
$code = http_response_code();
echo "There was a problem handling your form submission\n{$link->error}";
return;
} else {
http_response_code(200);
$code = http_response_code();
echo "Daily report approved\nreport #{$idrID}\n{$timestamp}";
return;
}
}
} elseif ($comment = $_POST['comment']) {
$commentQry = "INSERT idrComments (userID, comment, idrID, commentDate)
VALUES ('{$_POST['userID']}', '{$_POST['comment']}', {$idrID}, '{$timestamp}')";
$result = $link->query($commentQry);
if (!result) {
http_response_code(500);
$code = http_response_code();
echo "There was a problem adding your comment\n{$link->error}";
return;
} else {
http_response_code(201);
$code = http_response_code();
echo "Comment added";
return;
}
} else {
http_response_code(409);
$code = http_response_code();
echo "There was a problem with the request:\nNo data received";
}
}
?>