-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddTrivia.php
More file actions
140 lines (135 loc) · 6.18 KB
/
addTrivia.php
File metadata and controls
140 lines (135 loc) · 6.18 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
require_once 'lib/includes/utilities.inc.php';
include 'lib/functions/functions.inc.php';
//echo "<pre>" . print_r($_SESSION['user'], 1) . "</pre>\n";
/*
* Make sure non-members can't access page.
*/
if (!isset($_SESSION['user'])) {
header('Location: index.php');
exit();
} elseif (isset($_SESSION['user']) && $_SESSION['user']->security === 'public') {
header('Location: index.php');
exit();
}
createTables();
$categories = [];
$stmt = $pdo->query('SELECT category FROM trivia_questions'); // Grab ALL the categories:
/*
* Only put unique category into categories array
*/
while ($row = $stmt->fetch()) {
if (!in_array($row['category'], $categories)) {
array_push($categories, $row['category']);
}
}
$submit = filter_input(INPUT_POST, 'submit');
if (isset($submit) && $submit === 'enter') {
}
?>
<!DOCTYPE html>
<!--
Trivia Game Version 3.01 beta with XML;
by John Pepp
Started: January 31, 2017
Revised: March 2, 2017
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<title>Add ∥ Edit Trivia</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="lib/css/stylesheet.css">
</head>
<body>
<div id="shadow">
<div class="textBox">
<h2>Data Successfully Saved!</h2>
</div>
</div>
<div id="container" >
<div id="heading">
<h1>Trivia<span id="toxic">IntoXication</span></h1>
<h2 id="subheading">Don't Drive Drunk! Play this Game Instead!</h2>
</div>
<nav class="nav-bar">
<ul class="topnav" id="myTopnav">
<li><a class="top-link" href="#" > </a></li>
<li><a href="index.php">Home</a></li>
<li><a href="addTrivia.php">Add Trivia</a></li>
<?php
echo (isset($_SESSION['user']) ? '<li><a href="logout.php">Logout</a></li>' : NULL);
?>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li class="icon">
<a href='#'>☰</a>
</li>
</ul>
</nav>
<form id="add-categories-form" action="totalRecords.php" method="post">
<input type="hidden" name="modify" value="edit_entry">
<section id="first" class="section">
<div class="radioContainer">
<input type="radio" name="modify" value="new_entry" id="radio-1" checked>
<label for="radio-1"><span class="radio">New Entry</span></label>
</div>
<?php if ($_SESSION['user']->security === 'admin') { ?>
<div class="radioContainer">
<input type="radio" name="modify" value="edit_entry" id="radio-2">
<label for="radio-2"><span class="radio">Edit Entry</span></label>
</div>
<?php } ?>
</section>
<select id="category" name="category">
<?php
/*
* Only put unique categories into selection option value attribute
*/
foreach ($categories as $category) {
echo '<option value="' . $category . '">' . $category . '</option>';
}
?>
</select>
<input id="submitBtn" type="button" name="submit" value="submit">
</form>
<form id="addTrivia" action="update_trivia.php" method="post">
<fieldset>
<legend id="legend">Add Trivia Question(s)</legend>
<input id="id" type="hidden" name="id" value="0">
<input type="hidden" name="user_id" value="<?php echo (isset($_SESSION['user'])) ? $_SESSION['user']->id : NULL; ?>">
<input id="cat" type="hidden" name="category" value="">
<textarea id="addQuestion" name="question" tabindex="1" placeholder="Add question here..." autofocus></textarea>
<label for="addAnswer1">Answer 1</label>
<input id="addAnswer1" type="text" name="answer1" value="" tabindex="2">
<label for="addAnswer2">Answer 2</label>
<input id="addAnswer2" type="text" name="answer2" value="" tabindex="3">
<label for="addAnswer3">Answer 3</label>
<input id="addAnswer3" type="text" name="answer3" value="" tabindex="4">
<label for="addAnswer4">Answer 4</label>
<input id="addAnswer4" type="text" name="answer4" value="" tabindex="5">
<label for="addCorrect">Answer</label>
<input id="addCorrect" type="text" name="correct" value="" tabindex="6">
<div id="hiddenBox">
<label for="hidden">Hidden</label>
<input id="hidden" type="text" name="hidden" value="" tabindex="7">
</div>
<input id="prevBtn" type="submit" name="submit" value="prev" tabindex="8">
<input id="saveBtn" type="button" name="enter" value="save" tabindex="9">
<input id="nextBtn" type="submit" name="submit" value="next" tabindex="10">
</fieldset>
</form>
<noscript>
<div id="noScriptBox">
<p class="noscript">Sorry, This quiz requires Javascript to be enabled!</p>
<a href="https://www.pepster.com" title="Pepster's Place Website">https://www.pepster.com</a>
</div>
</noscript>
</div>
<div id="myFooter">
<p class="footer-text">©<?php echo date("Y"); ?> John R. Pepp <span>Dedicated to my mom 11-29-1928 / 02-26-2017</span></p>
</div>
<script src="lib/js/modify.js"></script>
</body>
</html>