-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_trivia.php
More file actions
41 lines (33 loc) · 1.06 KB
/
Copy pathupdate_trivia.php
File metadata and controls
41 lines (33 loc) · 1.06 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
<?php
require_once 'lib/includes/utilities.inc.php';
use website_project\trivia_game\Trivia;
$e = [];
$trivia = new Trivia();
$data['id'] = htmlspecialchars($_POST['id']);
$data['hidden'] = htmlspecialchars($_POST['hidden']);
$data['question'] = htmlspecialchars($_POST['question']);
$data['answer1'] = htmlspecialchars($_POST['answer1']);
$data['answer2'] = htmlspecialchars($_POST['answer2']);
$data['answer3'] = htmlspecialchars($_POST['answer3']);
$data['answer4'] = htmlspecialchars($_POST['answer4']);
$data['correct'] = htmlspecialchars($_POST['correct']);
foreach ($data as $key => $value) {
$data[$key] = html_entity_decode($value);
}
$result = $trivia->update($data);
if ($result) {
$e['result'] = TRUE;
$e['message'] = "Table Successfully Updated!";
output($e);
}
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);
}