-
Notifications
You must be signed in to change notification settings - Fork 0
/
reservationUpdate.php
223 lines (187 loc) · 6.95 KB
/
reservationUpdate.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
<!DOCTYPE html>
<html>
<?php
session_start();
require "menu.php";
require 'connectToDB.php';
$id = $cssn = $vid = $sdate = $fdate = $rdate = $paid = $sloc = $floc = $lplate = "";
$error = "";
if(isset($_GET['id']))
{
$id = $_GET["id"];
$_SESSION["id"] = $id;
$query = "SELECT * FROM reservation WHERE ReservationID='".$id."'";
if (!($query_run = mysqli_query($mysql_connection, $query))) {
$er = mysqli_error($mysql_connection);
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>$er<strong>.
</div>";
}
else
{
$row = mysqli_fetch_assoc($query_run);
$cssn = $row["SSN_cust"];
$vid = $row["VehicleID"];
$sdate = $row["StartDate"];
$fdate = $row["FinishDate"];
$rdate = $row["DateOfReserv"];
$paid = $row["Paid"];
$sloc = $row["StartLocation"];
$floc = $row["FinishLocation"];
$lplate = $row["LicensePlate"];
}
}
if(isset($_POST["submit"]))
{
//isset()
$cssn = isset($_POST['cssn']) ? $_POST['cssn'] : "";
//empty()
$cssn = !empty($_POST['cssn']) ? $_POST['cssn'] : "";
//isset()
$vid = isset($_POST['vid']) ? $_POST['vid'] : "";
//empty()
$vid = !empty($_POST['vid']) ? $_POST['vid'] : "";
//isset()
$sdate = isset($_POST['sdate']) ? $_POST['sdate'] : "";
//empty()
$sdate = !empty($_POST['sdate']) ? $_POST['sdate'] : "";
//isset()
$fdate = isset($_POST['fdate']) ? $_POST['fdate'] : "";
//empty()
$fdate = !empty($_POST['fdate']) ? $_POST['fdate'] : "";
//isset()
$rdate = isset($_POST['rdate']) ? $_POST['rdate'] : "";
//empty()
$rdate = !empty($_POST['rdate']) ? $_POST['rdate'] : "";
//isset()
$sloc = isset($_POST['sloc']) ? $_POST['sloc'] : "";
//empty()
$sloc = !empty($_POST['sloc']) ? $_POST['sloc'] : "";
//isset()
$floc = isset($_POST['floc']) ? $_POST['floc'] : "";
//empty()
$floc = !empty($_POST['floc']) ? $_POST['floc'] : "";
//isset()
$paid = isset($_POST['paid']) ? $_POST['paid'] : "";
//empty()
$paid = !empty($_POST['paid']) ? $_POST['paid'] : "";
//isset()
$lplate = isset($_POST['lplate']) ? $_POST['lplate'] : "";
//empty()
$lplate = !empty($_POST['lplate']) ? $_POST['lplate'] : "";
$id = $_SESSION["id"];
if(is_numeric($id))
{
if(is_numeric($cssn))
{
if(strlen($cssn) == 11)
{
if(is_numeric($vid))
{
$query = "UPDATE reservation SET `SSN_cust`='$cssn', `VehicleID`='$vid', `StartDate`='$sdate', `FinishDate`='$fdate', `DateOfReserv`='$rdate', `Paid`='$paid', `StartLocation`='$sloc', `FinishLocation`='$floc', `LicensePlate`='$lplate' WHERE `ReservationID`='$id'";
if (!mysqli_query($mysql_connection, $query))
{
$er = mysqli_error($mysql_connection);
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>$er<strong>.
</div>";
}
else
{
mysqli_close($mysql_connection);
header("Location:reservations.php");
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Ο κωδικός καταστήματος πρέπει να είναι αριθμός<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Το ΑΜΚΑ πρέπει να είναι 11 νούμερα<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Το ΑΜΚΑ πρέπει να είναι αριθμός<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Ο κωδικός αυτοκινήτου πρέπει να είναι αριθμός<strong>.
</div>";
}
}
?>
<body>
<div class="container">
<form method="post" action = "reservationUpdate.php">
<?php echo $error;?>
<div class="form-group row">
<label class="col-md-2 control-label">Reservation ID</label>
<div class="col-md-5">
<input type="text" class="form-control" name="id" placeholder="Reservation ID" value="<?php echo $id;?>" disabled />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Customer SSN Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="cssn" placeholder="Customer SSN Number" value="<?php echo $cssn;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Vehicle ID</label>
<div class="col-md-5">
<input type="text" class="form-control" name="vid" placeholder="Vehicle ID" value="<?php echo $vid;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Reservation Dates</label>
<div class="col-xs-3">
<input type="date" class="form-control" name="sdate" required value="<?php echo $sdate;?>" placeholder="Start Date"/>
</div>
<div class="col-xs-3">
<input type="date" class="form-control" name="fdate" value="<?php echo $fdate;?>" required placeholder="Finish Date"/>
</div>
<div class="col-xs-3">
<input type="date" class="form-control" name="rdate" value="<?php echo $rdate;?>" required placeholder="Reservation Date"/>
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Locations</label>
<div class="col-md-5">
<input type="text" class="form-control" name="sloc" required value="<?php echo $sloc;?>" placeholder="Start Location"/>
</div>
<div class="col-md-5">
<input type="text" class="form-control" name="floc" value="<?php echo $floc;?>" required placeholder="Finish Location"/>
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">License Plate</label>
<div class="col-md-5">
<input type="text" class="form-control" name="lplate" placeholder="License Plate" value="<?php echo $lplate;?>" required />
</div>
</div>
<div class="form-group row">
<label for="select" class="col-lg-2 control-label">Reservation Paid</label>
<div class="col-xs-3">
<select class="form-control" id="paid" name="paid" required>
<option value="">Select One</option>
<option value="YES">YES</option>
<option value="NO">NO</option>
</select>
</div>
</div>
<br></br>
<div class="form-group row">
<div class="col-md-offset-2 col-md-8">
<button type="submit" class="btn btn-success" name="submit">Submit</button>
</div>
</div>
</form>
</body>
</html>