-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertmovie.php
More file actions
83 lines (67 loc) · 2.5 KB
/
insertmovie.php
File metadata and controls
83 lines (67 loc) · 2.5 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
<?php
if (isset($_POST['submit'])) {
if ( isset($_POST['title']) &&
isset($_POST['length_']) && isset($_POST['trailer']) &&
isset($_POST['descriptionn']) &&
isset($_POST['show_time'])) {
$title = $_POST['title'];
$length = $_POST['length_'];
$trailer = $_POST['trailer'];
$description = $_POST['descriptionn'];
$show_time = $_POST['show_time'];
$image = $_FILES['imagee']['name'];
$target="upload/".basename($image);
$servername="localhost";
$username="root";
$password="";
$dbname="cinema";
$conn= new mysqli($servername,$username,$password,$dbname);
if (mysqli_connect_error()) {
die('Could not connect to the database('.mysqli_connect_errno().')'. mysqli_connect_error());
}
else {
$SELECT = "SELECT title FROM movie_table WHERE title = ? LIMIT 1";
$Insert = "INSERT INTO movie_table(title,length_,trailer,descriptionn,show_time,imagee) values(?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $title);
$stmt->execute();
$stmt->bind_result($title);
$stmt->store_result();
$stmt->fetch();
$rnum = $stmt->num_rows;
if ($rnum == 0) {
$stmt->close();
$stmt = $conn->prepare($Insert);
$stmt->bind_param("ssssss", $title, $length, $trailer,$description,$show_time,$image);
if ($stmt->execute()) {
echo "<script> alert('you have succesfuly entered a movie !!');
window.location.href='movielist.php';
</script>";
move_uploaded_file($_FILES['imagee']['tmp_name'],$target);
}
else {
echo $stmt->error;
}
}
else {
echo "<script> alert('this movie already exists !!');
window.location.href='movielist.php';
</script>";
exit() ;
}
$stmt->close();
$conn->close();
}
}
else {
echo "<script> alert('all fields are required !!');
window.location.href='movielist.php';
</script>";
exit() ;
die();
}
}
else {
echo "Submit button is not set";
}
?>