-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrentAdd.php
250 lines (221 loc) · 7.97 KB
/
rentAdd.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
<!DOCTYPE html>
<html>
<?php
require "menu.php";
require 'connectToDB.php';
$id = $essn = $cssn = $vid = $sdate = $fdate = $sloc = $floc = $ehand = $erec = $rstate = "";
$error = "";
if(isset($_POST["submit"]))
{
//isset()
$id = isset($_POST['id']) ? $_POST['id'] : "";
//empty()
$id = !empty($_POST['id']) ? $_POST['id'] : "";
//isset()
$essn = isset($_POST['essn']) ? $_POST['essn'] : "";
//empty()
$essn = !empty($_POST['essn']) ? $_POST['essn'] : "";
//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()
$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()
$ehand = isset($_POST['ehand']) ? $_POST['ehand'] : "";
//empty()
$ehand = !empty($_POST['ehand']) ? $_POST['ehand'] : "";
//isset()
$erec = isset($_POST['erec']) ? $_POST['erec'] : "";
//empty()
$erec = !empty($_POST['erec']) ? $_POST['erec'] : "";
//isset()
$rstate = isset($_POST['rstate']) ? $_POST['rstate'] : "";
//empty()
$rstate = !empty($_POST['rstate']) ? $_POST['rstate'] : "";
if(is_numeric($id))
{
if(is_numeric($essn))
{
if(strlen($essn) == 11)
{
if(is_numeric($cssn))
{
if(strlen($cssn) == 11)
{
if(is_numeric($vid))
{
if(is_numeric($ehand))
{
if(strlen($ehand)==11)
{
if(is_numeric($erec))
{
if(strlen($erec)==11)
{
$query = "INSERT INTO `rents` VALUES ('$id','$essn','$cssn','$vid','$sdate','$fdate','$sloc','$floc','$ehand','$erec','$rstate')";
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:rents.php");
}
}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>Το ΑΜΚΑ πρέπει να είναι 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>";
}
}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>";
}
}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>";
}
}else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Ο κωδικός ενοικίασης πρέπει να είναι αριθμος<strong>.
</div>";
}
}
?>
<body>
<div class="container">
<form method="post" action = "rentAdd.php">
<?php echo $error;?>
<div class="form-group row">
<label class="col-md-2 control-label">Rent ID</label>
<div class="col-md-5">
<input type="text" class="form-control" name="id" placeholder="Rent ID" value="<?php echo $id;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Employee SSN Number</label>
<div class="col-md-5">
<input type="text" class="form-control" name="essn" placeholder="Employee SSN Number" value="<?php echo $essn;?>" required />
</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">Rent Dates</label>
<div class="col-md-5">
<input type="date" class="form-control" name="sdate" required value="<?php echo $sdate;?>" placeholder="Start Date"/>
</div>
<div class="col-md-5">
<input type="date" class="form-control" name="fdate" value="<?php echo $fdate;?>" required placeholder="Start 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">Handing Employee's SSN</label>
<div class="col-md-5">
<input type="text" class="form-control" name="ehand" placeholder="SSN Number" value="<?php echo $ehand;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Receiving Employee's SSN</label>
<div class="col-md-5">
<input type="text" class="form-control" name="erec" placeholder="SSN Number" value="<?php echo $erec;?>" required />
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label">Return State</label>
<div class="col-md-5">
<input type="text" class="form-control" name="rstate" placeholder="Return State" value="<?php echo $rstate;?>" required />
</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>