-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
executable file
·171 lines (153 loc) · 6.26 KB
/
insert.php
File metadata and controls
executable file
·171 lines (153 loc) · 6.26 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Video Game Database</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- css -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/theme.bootstrap.css" rel="stylesheet">
<link href="css/select2.css" rel="stylesheet">
<!-- scripts -->
<script src="js/jquery-1.10.1.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/parsley.js"></script>
<script src="js/select2.js"></script>
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<style>
input.parsley-success, textarea.parsley-success {
color: #468847 !important;
background-color: #DFF0D8 !important;
border: 1px solid #D6E9C6 !important;
}
input.parsley-error, textarea.parsley-error {
color: #B94A48 !important;
background-color: #F2DEDE !important;
border: 1px solid #EED3D7 !important;
}
</style>
<script>
$(document).ready(function() {
$("#e4").select2({placeholder: "Select a Game Studio"});
});
$(document).ready(function () {
$("#e5").select2({placeholder: "Select Devices"});
});
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="index.php">Game On!</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="videogame.php">Video Games</a></li>
</ul>
<form class="navbar-search pull-right" action="search.php" action="get">
<input type="text" class="search-query" name="search" placeholder="Search">
</form>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<?php ini_set('display_errors',1);
error_reporting(E_ALL);
include_once("php/mysql.php");
if(isset($_POST['submit'])) {
$devices = null;
if(isset($_POST['name'])) $vg_name = $_POST['name'];
if(isset($_POST['year'])) $vg_year = $_POST['year'];
if(isset($_POST['optionRadios'])) $vg_rating = $_POST['optionRadios'];
if(isset($_POST['gamestudio'])) $vg_studio = $_POST['gamestudio'];
if(isset($_POST['devices'])) $devices = $_POST['devices'];
if(isset($_POST['url'])) $url = $_POST['url'];
$result = insert_new_video_game($vg_name, $vg_year, $vg_rating, $vg_studio, $devices, $url);
if(!$result) {
echo "<div class='alert alert-error'>Insert did not work!</div>";
}
echo "<div class='alert alert-success'>
<button type='button' class='close' data-dismiss='alert'>×</button>
Video Game '".$vg_name."' added!</div>";
}
?>
</div>
<div class="container">
<form class="form-horizontal" id="insert-game" data-validate="parsley" action="insert.php" method="post">
<legend>Insert New Video Game</legend>
<div class="control-group">
<label class="control-label" for="name">Name*</label>
<div class="controls">
<input placeholder="Name" type="text" id="name" name="name" data-required="true" data-rangelength="[1,40]"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Year Released*</label>
<div class="controls">
<input placeholder="YYYY" type="text" id="year" name="year" data-required="true" data-type="digits" data-maxlength="4" data-minlength="4"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="esbr">ESBR Rating*</label>
<div class="controls">
<label class="radio inline">
<input type="radio" name="optionRadios" id="esbr_e" value="3" checked>E
</label>
<label class="radio inline">
<input type="radio" name="optionRadios" id="esbr_t" value="2">T
</label>
<label class="radio inline">
<input type="radio" name="optionRadios" id="esbr_m" value="1">M
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="game_studio">Game Studio*</label>
<div class="controls">
<select name="gamestudio" style="width: 300px;" id="e4" data-required="true">
<option></option>
<?php
build_game_studio_options()
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="devices">Devices Supported</label>
<div class="controls">
<select multiple name="devices[]" style="width: 300px;" id="e5">
<option></option>
<?php build_device_options(); ?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="picture">Image URL</label>
<div class="controls">
<input class="input-xxlarge" type="text" id="url" name="url" data-type="url" data-maxlength="250"/>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary" id="submit" name="submit" value="insert">Submit</button>
<a href="videogame.php" class="btn">Cancel</a>
<span class="help-block" style="margin-top: 4px;"><small>*required</small></span>
</div>
</div>
</form>
</div>
</body>
</html>