-
Notifications
You must be signed in to change notification settings - Fork 8
/
update_plan.php
132 lines (120 loc) · 5.33 KB
/
update_plan.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
127
128
129
130
131
132
<?php
require 'db.php';
$id = $_GET['mbid'];
$exec = mysqli_query($con,"select * from banquet_plans where mbid = $id");
if(mysqli_num_rows($exec))
{
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="images/favicon-icon.png" type="image/x-icon">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<title>Update Banquet Plan</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/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>
<style>
h2{
padding: 10px;
text-align: center;
}
.form-group{
margin-right: 20%;
margin-left: 20%;
}
.custom-file{
margin-right: 20%;
margin-left: 20%;
}
.nav{
background-color: blue;
color: white;
font-size: 24px;
width: 100%;
}
.nav a{
color: white;
font-size: 24px;
text-decoration: none;
padding : 10px;
}
</style>
<?php
while($r = mysqli_fetch_array($exec))
{
?>
<body>
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" href="/admin_display_plan.php">Back</a>
<a class="flex-sm-fill text-sm-center nav-link" href="/admin_plan.html">Add Plan</a>
</nav>
<h2> Update Plan Details </h2>
<form method="post" action="#" enctype="multipart/form-data">
<div class="form-group">
<label>Plan Name </label>
<input type="text" class="form-control" id="exampleInputEmail1" name="plan" value="<?php echo $r['plan_name']; ?>" required />
</div>
<div class="form-group">
<label>Price</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="price" value="<?php echo $r['price']; ?>" required />
</div>
<div class="form-group">
<label>Feature List</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="feature" value="<?php echo $r['feature_list']; ?>" required /><br>
</div>
<div class="form-group">
<img src="<?php echo $r['img']; ?>" class="img-fluid" alt="Responsive image">
<p> <b>Note : </b> Current Image</p>
</div>
<div class="input-group mb-3">
<div class="custom-file">
<input type="file" class="custom-file-input" id="inputGroupFile01" name="image1" aria-describedby="inputGroupFileAddon01">
<label class="custom-file-label" for="inputGroupFile01">Choose file</label>
</div>
</div>
<button style="margin-left:40%;" type="submit" name="update" value="Update Plan" class="btn btn-primary"> Update plan </button>
<?php
}
}
?>
</form>
<?php
if(isset($_POST['update']))
{
$name = $_POST['plan'];
$price = $_POST['price'];
$feature = $_POST['feature'];
if(isset($_FILES['image1']['name']) && ($_FILES['image1']['name'] != "")){
$filename = $_FILES['image1']['name'];
$temp_file = $_FILES['image1']['tmp_name'];
$folder = "plan_image/".$filename;
$exec1 = mysqli_query($con,"select * from banquet_plans where mbid = $id");
while($r = mysqli_fetch_array($exec1)){
$f = $r['img'];
if($f != $folder)
{
move_uploaded_file($temp_file,$folder);
$exec2 = mysqli_query($con,"update banquet_plans set plan_name = '$name', price = $price, feature_list = '$feature',img = '$folder' where mbid = $id");
if($exec2)
echo '<script>alert("Plan Updated")</script>';
else
echo mysqli_error($con);
}
}
}
else{
$exec2 = mysqli_query($con,"update banquet_plans set plan_name = '$name', price = $price, feature_list = '$feature' where mbid = $id");
if($exec2)
echo '<script>alert("Plan Updated")</script>';
else
echo mysqli_error($con);
}
}
?>
</body>
</html>