-
Notifications
You must be signed in to change notification settings - Fork 0
/
customerUpdate.php
316 lines (275 loc) · 10.4 KB
/
customerUpdate.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE html>
<html>
<?php
session_start();
require "menu.php";
require 'connectToDB.php';
$id = $irs = $fname = $lname = $driverl = $idn = $first = $country = $city = $street = $streetn = $postal = $phone = $email = $type = "";
$error = "";
if(isset($_GET['id']))
{
$id = $_GET["id"];
$_SESSION["id"] = $id;
$query = "SELECT * FROM customers WHERE SSN_cust='".$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);
$irs = $row["IRS_cust"];
$lname = $row["LastName"];
$fname = $row["FirstName"];
$driverl = $row["DriverLicense"];
$idn = $row["IdentityNumber"];
$first = $row["FirstRegistration"];
$country = $row["Country"];
$city = $row["City"];
$street = $row["Street"];
$streetn = $row["StreetNumber"];
$postal = $row["PostalCode"];
$phone = $row["PhoneNumber"];
$email = $row["E-mail"];
$type = $row["cust_Type"];
}
}
if(isset($_POST["submit"]))
{
//isset()
$irs = isset($_POST['irs']) ? $_POST['irs'] : "";
//empty()
$irs = !empty($_POST['irs']) ? $_POST['irs'] : "";
//isset()
$idn = isset($_POST['idn']) ? $_POST['idn'] : "";
//empty()
$idn = !empty($_POST['idn']) ? $_POST['idn'] : "";
//isset()
$lname = isset($_POST['lname']) ? $_POST['lname'] : "";
//empty()
$lname = !empty($_POST['lname']) ? $_POST['lname'] : "";
//isset()
$fname = isset($_POST['fname']) ? $_POST['fname'] : "";
//empty()
$fname = !empty($_POST['fname']) ? $_POST['fname'] : "";
//isset()
$driverl = isset($_POST['driverl']) ? $_POST['driverl'] : "";
//empty()
$driverl = !empty($_POST['driverl']) ? $_POST['driverl'] : "";
//isset()
$first = isset($_POST['first']) ? $_POST['first'] : "";
//empty()
$first = !empty($_POST['first']) ? $_POST['first'] : "";
//isset()
$country = isset($_POST['country']) ? $_POST['country'] : "";
//empty()
$country = !empty($_POST['country']) ? $_POST['country'] : "";
//isset()
$city = isset($_POST['city']) ? $_POST['city'] : "";
//empty()
$city = !empty($_POST['city']) ? $_POST['city'] : "";
//isset()
$street = isset($_POST['street']) ? $_POST['street'] : "";
//empty()
$street = !empty($_POST['street']) ? $_POST['street'] : "";
//isset()
$streetn = isset($_POST['streetn']) ? $_POST['streetn'] : "";
//empty()
$streetn = !empty($_POST['streetn']) ? $_POST['streetn'] : "";
//isset()
$postal = isset($_POST['postal']) ? $_POST['postal'] : "";
//empty()
$postal = !empty($_POST['postal']) ? $_POST['postal'] : "";
//isset()
$phone = isset($_POST['phone']) ? $_POST['phone'] : "";
//empty()
$phone = !empty($_POST['phone']) ? $_POST['phone'] : "";
//isset()
$email = isset($_POST['email']) ? $_POST['email'] : "";
//empty()
$email = !empty($_POST['email']) ? $_POST['email'] : "";
//isset()
$type = isset($_POST['type']) ? $_POST['type'] : "";
//empty()
$type = !empty($_POST['type']) ? $_POST['type'] : "";
$id = $_SESSION["id"];
if(is_numeric($id))
{
if(strlen($id) == 11)
{
if(is_numeric($irs))
{
if(strlen($irs) == 9)
{
if(is_numeric($streetn))
{
if(is_numeric($postal))
{
if(is_numeric($driverl))
{
if(is_numeric($phone))
{
$query = "UPDATE customers SET IRS_cust='$irs', IdentityNumber='$idn', LastName='$lname', FirstName='$fname', Cust_Type='$type', Country='$country', DriverLicense='$driverl', City='$city', `E-mail`='$email', Street='$street', StreetNumber='$streetn', PostalCode='$postal', PhoneNumber='$phone' WHERE SSN_cust='$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:customers.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>Η άδεια οδήγησης πρέπει να είναι αριθμός<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>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>To ΑΦΜ πρέπει να είναι 9 νούμερα<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>To ΑΦΜ πρέπει να είναι αριθμός<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>To ΑΜΚΑ πρέπει να είναι 11 νούμερα<strong>.
</div>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>To ΑΜΚΑ πρέπει να είναι αριθμός<strong>.
</div>";
}
}
?>
<body>
<div class="container">
<form method="post" action = "customerUpdate.php">
<?php echo $error;?>
<div class="form-group row">
<label class="col-md-2 control-label">SSN Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="id" placeholder="SSN Number" value="<?php echo $id;?>" disabled />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">IRS Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="irs" placeholder="Irs Number" value="<?php echo $irs;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Identity Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="idn" placeholder="Identity Number" value="<?php echo $idn;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Full Name</label>
<div class="col-md-5">
<input type="text" class="form-control" name="fname" required value="<?php echo $fname;?>" placeholder="First Name"/>
</div>
<div class="col-md-5">
<input type="text" class="form-control" name="lname" placeholder="Last Name" value="<?php echo $lname;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Driver's License</label>
<div class="col-md-5">
<input type="text" class="form-control" name="driverl" placeholder="License ID" value="<?php echo $driverl;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">First Registration</label>
<div class="col-md-5">
<input type="date" class="form-control" name="first" required value="<?php echo $first;?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Country</label>
<div class="col-md-5">
<input type="text" class="form-control" name="country" placeholder="Country Name" value="<?php echo $country;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">City</label>
<div class="col-md-5">
<input type="text" class="form-control" name="city" placeholder="City Name" value="<?php echo $city;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Street Address</label>
<div class="col-md-5">
<input type="text" class="form-control" name="street" placeholder="Street Name" value="<?php echo $street;?>" required />
</div>
<div class="col-md-5">
<input type="text" class="form-control" name="streetn" placeholder="Street Number" value="<?php echo $streetn;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Postal Code</label>
<div class="col-md-5">
<input type="text" class="form-control" name="postal" placeholder="Postal Code" value="<?php echo $postal;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Contact Information</label>
<div class="col-md-5">
<input type="text" class="form-control" name="phone" required value="<?php echo $phone;?>" placeholder="Phone Number"/>
</div>
<div class="col-md-5">
<input type="email" class="form-control" name="email" placeholder="E-mail Address" value="<?php echo $email;?>" required />
</div>
</div>
<div class="form-group row">
<label for="select" class="col-lg-2 control-label">Customer Type</label>
<div class="col-lg-10">
<select class="form-control" id="type" name="type" required>
<option value="">Select One</option>
<option value="Company">Company</option>
<option value="Private Citizen">Private Citizen</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>