-
Notifications
You must be signed in to change notification settings - Fork 3
/
addmovie.php
65 lines (53 loc) · 2.44 KB
/
addmovie.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
59
60
61
62
63
64
65
<?php
include "connection.php";
if($_POST['id_tvseries_tmdb'] == 0){
$sthandler = $conn->prepare("SELECT id FROM `movies` WHERE id = :id");
$sthandler->bindParam(':id', $_POST['id']);
$sthandler->execute();
if($sthandler->rowCount() > 0){
echo "exists! cannot insert";
} else {
$sql = "INSERT INTO `movies` (`id`, `title`, `file_id`) VALUES (:id, :title, :file_id)";
$statement = $conn->prepare($sql);
$statement->bindValue(':id', $_POST['id']);
$statement->bindValue(':title', $_POST['title']);
$statement->bindValue(':file_id', $_POST['file_id']);
$inserted = $statement->execute();
if($inserted){
echo "Add Movie Done!";
}
}
}else{
$sthandler = $conn->prepare("SELECT id_tvseries_tmdb ,episode_id_tmdb FROM `tv_series` WHERE id_tvseries_tmdb = :id_tvseries_tmdb AND episode_id_tmdb = :episode_id_tmdb");
$sthandler->bindParam(':id_tvseries_tmdb', $_POST['id_tvseries_tmdb']);
$sthandler->bindParam(':episode_id_tmdb', $_POST['episode_id_tmdb']);
$sthandler->execute();
if($sthandler->rowCount() > 0){
echo "exists! cannot insert tv episode ";
} else {
$sql = "INSERT INTO `tv_series` (`id_tvseries_tmdb`,
`name_tv_series`,
`season_number`,
`episode_name`,
`episode_number`,
`episode_id_tmdb` )
VALUES (:id_tvseries_tmdb,
:name_tv_series,
:season_number,
:episode_name,
:episode_number,
:episode_id_tmdb )";
$statement = $conn->prepare($sql);
$statement->bindValue(':id_tvseries_tmdb', $_POST['id_tvseries_tmdb']);
$statement->bindValue(':name_tv_series', $_POST['name_tv_series']);
$statement->bindValue(':season_number', $_POST['season_number']);
$statement->bindValue(':episode_name', $_POST['episode_name']);
$statement->bindValue(':episode_number', $_POST['episode_number']);
$statement->bindValue(':episode_id_tmdb', $_POST['episode_id_tmdb']);
$inserted = $statement->execute();
if($inserted){
echo "Add tv episode Done!";
}
}
}
?>