-
Notifications
You must be signed in to change notification settings - Fork 2
/
add_movie.php
58 lines (42 loc) · 1.07 KB
/
add_movie.php
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
<?php
include __DIR__ . '/includes/open_db_conn.php';
$query ="SELECT * FROM categories ORDER BY `name` ASC";
$result = $conn->query($query);
if (!$result) {
echo 'Si è verificato un errore';
var_dump($query);
exit();
}
$categories = [];
if ($result && $result->num_rows > 0) {
while ($cat = $result->fetch_assoc()) {
$categories[] = $cat;
}
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once __DIR__ . '/includes/head.inc' ?>
<title>Add Movie</title>
</head>
<body>
<div class="container p-5">
<header>
<h1>Add Movie</h1>
</header>
<main>
<form action="store_movie.php" method="POST">
<input type="text" name="title" placeholder="Nome Film" required />
<select name="category_id" >
<?php foreach ($categories as $cat) { ?>
<option value="<?php echo $cat['id']; ?>"><?php echo $cat['name']; ?></option>
<?php } ?>
</select>
<button class="btn btn-primary" type="submit">Aggiungi</button>
</form>
</main>
</div>
</body>
</html>