-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit-plant-record.php
283 lines (261 loc) · 16.7 KB
/
edit-plant-record.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<!-- Plant record editing -->
<?php
// Session start
session_start();
// Silence error reporting
error_reporting(0);
// Import the neccessary scripts
include('includes/dbconnection.php');
include('includes/functions.php');
// Logic for access Verification
if (strlen($_SESSION['smaid']==0)) {
// if not authenticated redirect them to index page
header('location:logout.php');
} else{
if(isset($_POST['submit'])){
// PH limits
$ph_Upper = 14;
$Lower = 0;
// Collect data from the form
$ph_H =(float)dataVerification($_POST['Highest_PH']);
$ph_L =(float)dataVerification($_POST['Lowest_PH']);
$tmp_H =(float)dataVerification($_POST['Lowest_Temp']);
$tmp_L =(float)dataVerification($_POST['Highest_Temp']);
$phosphorus =(float)dataVerification($_POST['Phosphorus']);
$nitrogen =(float)dataVerification($_POST['Nitrogen']);
$potassium =(float)dataVerification($_POST['Potassium']);
$name =ucwords(dataVerification($_POST['Plantname']), " ");
$id = $_SESSION['edtplantid'];
// Update the database records
$sql = "UPDATE plant_records SET Plant_name ='$name', Ph_high='$ph_H', Ph_low='$ph_L', Temp_high='$tmp_H', Temp_low='$tmp_L', Nitrogen='$nitrogen', Phosphorus='$phosphorus', Potassium='$potassium' where ID='$id'";
if($Conn->query($sql)){
echo'<script>alert("Edited successfully");</script>';
echo"<script type='text/javascript'> document.location ='edit-plant-record.php'; </script>";
}
}
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<title>Edit Plant Record | Smart Farming System</title>
<!-- Bootstrap CSS
============================================ -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Bootstrap CSS
============================================ -->
<link rel="stylesheet" href="css/font-awesome.min.css">
<!-- adminpro icon CSS
============================================ -->
<link rel="stylesheet" href="css/adminpro-custon-icon.css">
<!-- meanmenu icon CSS
============================================ -->
<link rel="stylesheet" href="css/meanmenu.min.css">
<!-- mCustomScrollbar CSS
============================================ -->
<link rel="stylesheet" href="css/jquery.mCustomScrollbar.min.css">
<!-- animate CSS
============================================ -->
<link rel="stylesheet" href="css/animate.css">
<!-- modals CSS
============================================ -->
<link rel="stylesheet" href="css/modals.css">
<!-- normalize CSS
============================================ -->
<link rel="stylesheet" href="css/normalize.css">
<!-- forms CSS
============================================ -->
<link rel="stylesheet" href="css/form/all-type-forms.css">
<!-- style CSS
============================================ -->
<link rel="stylesheet" href="style.css">
<!-- responsive CSS
============================================ -->
<link rel="stylesheet" href="css/responsive.css">
<!-- modernizr JS
============================================ -->
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body class="materialdesign">
<div class="wrapper-pro">
<!-- Import the sidebar and header-->
<?php include_once('includes/sidebar.php');?>
<?php include_once('includes/header.php');?>
<!-- Breadcome start-->
<div class="breadcome-area mg-b-30 small-dn">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="breadcome-list shadow-reset">
<div class="row">
<div class="col-lg-12">
<ul class="breadcome-menu">
<li><a href="dashboard.php">Home</a> <span class="bread-slash">/</span>
</li>
<li><span class="bread-blod">Plant Registration Form</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Basic Form Start -->
<div class="basic-form-area mg-b-15">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="sparkline12-list shadow-reset mg-t-30">
<div class="sparkline12-hd">
<div class="main-sparkline12-hd">
<h1>New Plant Application Form</h1>
<div class="sparkline12-outline-icon">
<span class="sparkline12-collapse-link"><i class="fa fa-chevron-up"></i></span>
<span><i class="fa fa-wrench"></i></span>
<span class="sparkline12-collapse-close"><i class="fa fa-times"></i></span>
</div>
</div>
</div>
<div class="sparkline12-graph">
<div class="basic-login-form-ad">
<div class="row">
<div class="col-lg-12">
<div class="all-form-element-inner">
<form method="post">
<?php
// Fetch the row to be edited
$id = $_SESSION['editplant'];
$sql="SELECT * from plant_records where ID ='$id'" ;
// Querry the database
$query = $Conn->query($sql);
// Fetch data as an associated array
$row = $query->fetch_assoc();
$_SESSION['edtplantid']=$row['ID'];
?>
<div class="form-group-inner mt-3">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">Name</label>
</div>
<div class="col-lg-8">
<input type="text" name="Plantname" class="form-control" value="<?php echo $row['Plant_name'];?>" required/>
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">PH</label>
</div>
<div class="col-lg-4">
<input type="text" class="form-control" name="Highest_PH" value="<?php echo $row['Ph_high'];?>" pattern="^\d*\.{0,1}\d+$" placeholder="Highest PH" required/>
</div>
<div class="col-lg-4">
<input type="text" class="form-control" name="Lowest_PH" pattern="^\d*\.{0,1}\d+$" value="<?php echo $row['Ph_low'];?>" placeholder="Lowest PH" required/>
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">Temperature</label>
</div>
<div class="col-lg-4">
<input type="text" pattern="^\d*\.{0,1}\d+$" class="form-control" name="Highest_Temp" placeholder="Highest Temperature" value="<?php echo $row['Temp_high'];?>" required/>
</div>
<div class="col-lg-4">
<input type="text" class="form-control" pattern="^\d*\.{0,1}\d+$" name="Lowest_Temp" placeholder="Lowest Temperature" value="<?php echo $row['Temp_low'];?>" required/>
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">Nitrogen</label>
</div>
<div class="col-lg-8">
<input type="text" class="form-control" pattern="^\d*\.{0,1}\d+$" name="Nitrogen" value="<?php echo $row['Nitrogen'];?>" required="true" />
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">Phosphorus</label>
</div>
<div class="col-lg-8">
<input type="text" name="Phosphorus" class="form-control" pattern="^\d*\.{0,1}\d+$" value="<?php echo $row['Phosphorus'];?>" required="true" />
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3">
<label class="login2 pull-right pull-right-pro">Potassium</label>
</div>
<div class="col-lg-8">
<input type="text" class="form-control" name="Potassium" value="<?php echo $row['Potassium'];?>" required="true" />
</div>
</div>
</div>
<div class="form-group-inner">
<div class="login-btn-inner">
<div class="row">
<div class="col-lg-3"></div>
<div class="col-lg-9">
<div class="login-horizental cancel-wp pull-left">
<button class="btn btn-sm btn-primary login-submit-cs" type="submit" name="submit" style="background:black">Register Plant</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Basic Form End-->
</div>
</div>
<!-- jquery
============================================ -->
<script src="js/vendor/jquery-1.11.3.min.js"></script>
<!-- bootstrap JS
============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- meanmenu JS
============================================ -->
<script src="js/jquery.meanmenu.js"></script>
<!-- mCustomScrollbar JS
============================================ -->
<script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
<!-- sticky JS
============================================ -->
<script src="js/jquery.sticky.js"></script>
<!-- scrollUp JS
============================================ -->
<script src="js/jquery.scrollUp.min.js"></script>
<!-- counterup JS
============================================ -->
<script src="js/counterup/jquery.counterup.min.js"></script>
<script src="js/counterup/waypoints.min.js"></script>
<!-- modal JS
============================================ -->
<script src="js/modal-active.js"></script>
<!-- icheck JS
============================================ -->
<script src="js/icheck/icheck.min.js"></script>
<script src="js/icheck/icheck-active.js"></script>
<!-- main JS
============================================ -->
<script src="js/main.js"></script>
</body>
</html><?php } ?>