-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
126 lines (110 loc) · 5.56 KB
/
edit.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include('connection.php');
$pid=$_GET['pid'];
$sel="select * from products where id='$pid'";
$rel=$con->query($sel);
$data=mysqli_fetch_array($rel);
include("adminmenu.php");
?>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<br>
<center><h2 class="font-alt">Edit Food Items</h2></center>
<br>
<form action="" class="form contact-form" enctype="multipart/form-data" method="post">
<div class="clearfix">
<div class="form-group">
<input type="text" name="pname" value="<?php echo $data['p_name']?>" class="input-md round form-control" placeholder="Enter Food Name" required>
</div>
<div class="form-group">
<select name="category" id="category" class="input-md form-control" required>
<option><?php echo $data['category']?></option>
<option value="Breakfast">Breakfast</option>
<option value="Starter">Starter</option>
<option value="Meal">Meal</option>
<option value="Beverages">Beverages</option>
<option value="Desert">Desert</option>
<option value="Rice">Rice</option>
<option value="Snacks">Snacks</option>
</select>
</div>
<div class="form-group">
<label style='font-size:15px;'>Food Image: </label><br>
<input type="text" name="img" value="<?php echo $data['image']?>"><br>
<input type="file" style='font-size:15px;width:35%' name="image" >
</div>
<!-- Password -->
<div class="form-group">
<textarea name="description" class="input-md round form-control" placeholder="Enter Food Description" style='height:90px' required><?php echo $data['description']?></textarea>
</div>
<!-- Phone No.-->
<div class="form-group">
<input type="text" name="price" class="input-md round form-control" placeholder="Enter Price" value="<?php echo $data['price']?>" pattern="[0-9]*$" title='Please Enter In numbers only' required>
</div>
<div class="form-group">
<input type="text" name="time" style='width:85%' class="input-md round form-control" placeholder="Enter Preparation time" pattern="[0-9]*$" title='Please Enter time in minutes' value="<?php echo $data['time']?>" required> Minutes
</div>
</div>
<!-- Send Button -->
<div class="pt-10">
<!---- <button class="submit_btn btn btn-mod btn-medium btn-round btn-full" id="reg-btn">Register</button>
--->
<input type="submit" name='add' class="btn btn btn-mod btn-medium btn-round btn-full"/>
</div>
<?php
if(isset($_POST['add']))
{
$file=$_FILES['image']['tmp_name'];
echo $iname=$_FILES['image']['name'];
if(isset($iname))
{
if(!empty($iname))
{
$location = 'images/';
if(move_uploaded_file($file, $location.$iname))
{
echo 'uploaded';
}
}
}
else
{
echo 'please upload';
}
$pname=$_POST['pname'];
$img=$iname;
$price=$_POST['price'];
$desc=$_POST['description'];
$cat=$_POST['category'];
$image=$_POST['img'];
$time=$_POST['time'];
if(empty($img))
{
$sql="update products set p_name='$pname', image='$image' , price='$price' ,description='$desc', category='$cat', time='$time' where id='$pid'";
if(mysqli_query( $con,$sql))
{
echo "<script>alert('Food Item Updated Succesfully');</script>";
echo "<script>window.location.href='manageitems.php'</script>";
}
else
{
echo "<script>alert('Please Try Again');</script>";
}
}
else{
$sql= "update products set p_name='$pname', image='$img' , price='$price' ,description='$desc', category='$cat',time='$time' where id='$pid'";
if(mysqli_query( $con,$sql))
{
echo "<script>alert('Food Item Updated Succesfully');</script>";
echo "<script>window.location.href='manageitems.php'</script>";
}
else
{
echo "<script>alert('Please Try Again');</script>";
}
}
}
?>
</form>
</div>
</div>