-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadd-product.php
85 lines (69 loc) · 2.97 KB
/
add-product.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include 'protect.php';
if ( isset($_REQUEST["title"]) )
{
$title = $_REQUEST["title"];
$description = $_REQUEST["description"];
$genre = $_REQUEST["genre"];
$target_dir = "uploads/";//456789_kk.png
$target_file = $target_dir . rand(1000000,10000000)."_".basename($_FILES["poster"]["name"]);
$file_extension = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));//png jpg
if (move_uploaded_file($_FILES["poster"]["tmp_name"], $target_file)) {
//echo "Uploaded";
$upload_status = 1;
}
require 'connect.php';
$sql = "INSERT INTO `products`(`id`, `title`, `description`, `genre`, `poster`)
VALUES (null,'$title','$description','$genre','$target_file')";
mysqli_query($con, $sql) or die(mysqli_error($con));
header("location:add-product.php");
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Form</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<?php include 'nav.php' ?>
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-5">
<h4>New Movie</h4>
<form action="add-product.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>Title</label>
<input type="text" class="form-control" name="title" required>
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" class="form-control"></textarea>
</div>
<div class="form-group">
<label>Genre</label>
<select name="genre" class="form-control">
<option value="Thriller">Thriller Movie</option>
<option value="Comedy">Comedy Movies</option>
<option value="Horror">Horror Movie</option>
<option value="Action">Action Movie</option>
<option value="Romance">Romance Movie</option>
</select>
</div>
<div class="form-group">
<label>Poster</label>
<input type="file" accept="image/*" class="form-control-file border" name="poster" required>
</div>
<button class="btn btn-success">Add Movie</button>
</form>
</div>
</div>
</div>
</body>
</html>