-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotalRecords.php
More file actions
38 lines (29 loc) · 919 Bytes
/
totalRecords.php
File metadata and controls
38 lines (29 loc) · 919 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
require_once 'lib/includes/utilities.inc.php';
use website_project\trivia_game\Trivia;
/* Makes it so we don't have to decode the json coming from JQuery */
header('Content-type: application/json');
$trivia = new Trivia();
$submit = htmlspecialchars($_POST['submit']);
if (isset($submit)) {
$category = htmlspecialchars($_POST['category']);
$modify = htmlspecialchars($_POST['modify']);
if ($modify === 'edit_entry') {
$data = $trivia->categories($category);
output($data);
} else {
$data = ['status' => 'new', 'category' => $category, 'total' => 0];
output($data);
}
}
function errorOutput($output, $code = 500) {
http_response_code($code);
echo json_encode($output);
}
/*
* If everything validates OK then send success message to Ajax / JavaScript
*/
function output($output) {
http_response_code(200);
echo json_encode($output);
}