forked from ITArif/Online-Movie-Ticket-Booking-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addfood.php
94 lines (80 loc) · 3.18 KB
/
addfood.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
85
86
87
88
89
<?php
include_once "connection/conn.php";
?>
<?php include_once "file/header.php"; ?>
<section class="contentsection clear">
<?php include_once "file/sidebar.php"; ?>
<article class="maincontent clear">
<div class="content">
<h2>Add food name & price & Image</h2>
<?php
if ($_SERVER["REQUEST_METHOD"]=="POST") {
$fid=$_POST["fid"];
$fname=$_POST["fname"];
$image=$_POST["image"];
$price=$_POST["price"];
$fcategory=$_POST["fcategory"];
$image = basename($_FILES['image']['name']);
$target_file = "common/images/$image";
move_uploaded_file($_FILES['image']['tmp_name'], $target_file);
if (empty($fname) || empty($image) || empty($price) || empty($fcategory)) {
echo "Nothing empty";
}else{
$sql="SELECT * FROM tbl_food where food_name='$fname'";
$query=mysqli_query($connection,$sql);
$row=mysqli_num_rows($query);
if ($row<1) {
$sql="INSERT INTO tbl_food (food_id,food_name,image,price,foot_category) VALUES('$fid',$fname','$image','$price','$fcategory');";
$query=mysqli_query($connection,$sql);
if ($query) {
echo "Info is inserted";
}
}else{
echo "exist";
}
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Food id</td>
<td><input type="text" name="fid" placeholder="Food id"/></td>
</tr>
<tr>
<td>Food Name</td>
<td><input type="text" name="fname" placeholder="Food Name"/></td>
</tr>
<tr>
<td>Food Image</td>
<td><input type="file" name="image"/></td>
</tr>
<tr>
<td>Food Price</td>
<td><select name="price">
<option value="">Select Pricet</option>
<option value="400">300 TK</option>
<option value="450">400 TK</option>
<option value="500">500 TK</option>
<option value="600">100 TK</option>
</select>
</td>
</tr>
<br>
<tr>
<td>Food Category</td>
<td><input type="text" name="fcategory" placeholder="Food Catagory"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Add"/></td>
</tr>
</table>
</form>
</div>
</article>
</section>
<?php include_once "file/footer.php"; ?>
</div>
</body>
</html>