-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_item.php
32 lines (25 loc) · 1.17 KB
/
add_item.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
<?php
require_once('access_db.php');
if (isset($_POST['submit'])) {
$title = $_POST['title'];
$runtime = filter_var($_POST['runtime'], FILTER_VALIDATE_INT) ?: null;
$year = filter_var($_POST['year'], FILTER_VALIDATE_INT) ?: null;
$director = $_POST['director'];
$produced = $_POST['country'];
$language = $_POST['language'];
$image_url = filter_var($_POST['image_url'], FILTER_VALIDATE_URL) ?: null;
if (isset($_POST['favourite'])){
$favourite = ($_POST['favourite']=='on') ? 'Y' : '';
}
$query = $db->prepare('INSERT INTO `films` (`Title`, `Running time`, `Year`, `Director`, `Produced`, `Language`, `image_url`, `favourite`) VALUES (:title, :runtime, :year, :director, :country, :language, :image_url, :favourite)');
$query->bindParam(':title', $title);
$query->bindParam(':runtime', $runtime);
$query->bindParam(':year', $year);
$query->bindParam(':director', $director);
$query->bindParam(':country', $produced);
$query->bindParam(':language', $language);
$query->bindParam(':image_url', $image_url);
$query->bindParam(':favourite', $favourite);
$query->execute();
header('Location: index.php');
}