-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-add.php
70 lines (58 loc) · 2.84 KB
/
admin-add.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
66
67
68
69
70
<html>
<head>
<title>Admin-MovieBooking</title>
<link rel="stylesheet" href="adminStyles.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="header">
<div class="header-item">
<h2>BookMyMovie</h2>
</div>
<div class="header-item">
<a id="menu-item" href="#">Logout</a>
</div>
</div>
<div class="body-content">
<div class="dash-head">
<a id="menu-dash" href="admin.php">Movies</a>
<a id="menu-dash" href="admin-add.php">Add Movie</a>
</div>
<div>
<form id="register-form" action="#" method="POST">
<h4 class="form-add">Add a new movie?</a></h4>
<input type="text" class="login-input" id="name" name="title" placeholder="Movie name" required />
<input type="text" class="login-input" id="age" name="cast" placeholder="Cast" required />
<input type="date" class="login-input" id="email-register" name="releasedate" placeholder="Release-date" required />
<input type="text" class="login-input" id="mobile" name="url" placeholder="Trailer URL" required />
<input type="text" class="login-input" name="imagepath" placeholder="Image path" required />
<button type="submit" class="login-input" name="add" id="submit-btn">Add movie</button>
</form>
</div>
</div>
</body>
</html>
<?php
if(isset($_POST['add'])){
include 'includes/config.php';
$title = $_POST['title'];
$cast = $_POST['cast'];
$date = $_POST['releasedate'];
$url = $_POST['url'];
$image = $_POST['imagepath'].'.jpg';
$qry = "INSERT INTO movies (`movieName`,`cast`,`releaseDate`,`trailerURL`,`image`)
VALUES('$title','$cast','$date','$url','$image')";
$result = $conn->query($qry);
if($result == TRUE){
echo "<script type = \"text/javascript\">
alert(\"Movie added successfully.\");
window.location = (\"admin.php\")
</script>";
} else{
// echo "Error: " . $qry . "<br>" . $conn->error;
echo "<script type = \"text/javascript\">
alert(\"Add failed\");
window.location = (\"admin-add.php\")
</script>";
}
}
?>