-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_item.php
235 lines (176 loc) · 6.16 KB
/
add_item.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
<!DOCTYPE html>
<html>
<head>
<title>Uploading Vehicle</title>
<link rel="stylesheet" type="text/css" href="signup.css">
</head>
<body>
<div class = "navbar">
<div class= "logo1">
<img src="images/logos.jpg" width = "125px">
</div>
<nav>
<ul>
<li><a href="">Home</a></li>
<li><a href="add_buyer.php">Register</a></li>
<li><a href="login.php">Login</a></li>
</ul>
</nav>
</div>
<?php
echo "<div class='signup-box'>";
echo "<form name='regform' action='check_item.php' onsubmit='return validationn()' method='POST' enctype = 'multipart/form-data'>";
if(isset($_GET["vehicle"]))
{
if($_GET["vehicle"] == "duplicate")
{
echo "<h4>Already entered this Vehicle</h4>";
echo "<br>";
echo "<h4>Please try again</h4>";
}
else if($_GET["vehicle"] == "successful")
{
echo "<h4>Successfully added the vehicle</h4>";
}
}
else
{
echo "<h4>Please upload your vehicle</h4>";
}
//here is the script for js validation
echo "<script>
function retroactive(date){
current_time=new Date().getTime();
time_given=new Date(date).getTime();
if(time_given < current_time){
return false;
}
else
{
return true;
}
}
function validationn() {
//initialize all the variables here
//get the username from the form ...we will use the name regform since we specified it in the form name='regform'
vehicle_type = document.forms['regform']['vehicle_type'];
var vehicle_number_plate = document.forms['regform']['vehicle_number_plate'];
var vehicle_description = document.forms['regform']['vehicle_description'];
var vehicle_picture = document.forms['regform']['vehicle_picture'];
var vehicle_price = document.forms['regform']['vehicle_price'];
var payment_method = document.forms['regform']['payment_method'];
var vehicle_category = document.forms['regform']['vehicle_category'];
var vehicle_seller = document.forms['regform']['vehicle_seller'];
//add more variables here eg email gender etc
//validate if the type is not empty
if (vehicle_type.value.length < 3) {
window.alert('Please enter your vehicle type of minimum 4 characters.');
//move the cursor to vehicle_type
username.focus();
return false;
}
//validate if plate is not empty
if(vehicle_number_plate.value.length < 6){
window.alert('please enter vehicle plate of minimum 6 characters.');
window.focus();
return false;
}
//validate if description is not empty
if(vehicle_description.value.length < 10){
window.alert('please enter your vehicle description.');
window.focus();
return false;
}
//validate if picture is not empty
if(vehicle_picture.value == ''){
window.alert('please upload vehicle image.');
window.focus();
return false;
}
//validate if price is not empty
if(vehicle_price.value == ''){
window.alert('please enter vehicle price.');
window.focus();
return false;
}
//validate if payment method is not empty
if(payment_method.value == ''){
window.alert('please select your preferred payment method.');
window.focus();
return false;
}
//validate if category is not empty
if(vehicle_category.value == ''){
window.alert('please select vehicle category.');
window.focus();
return false;
}
//validate if seller is not empty
if(vehicle_seller.value.length < 10){
window.alert('please enter seller description.');
window.focus();
return false;
}
//add more validations for gender password blablabla here
}
</script>";
echo "<label for='vehicle_type'>Vehicle Type</label>";
echo "<input type = 'text' name= 'vehicle_type' placeholder='vehicle type' >";
echo "<datalist id='vehicle_type'>
<option value='Toyota'>
<option value='Mercedes Benz'>
<option value='Mazda'>
<option value='Volvo'>
<option value='Land Rover'>
<option value='Nissan'>
<option value='Tesla'>
<option value='Tata'>
<option value='Ford'>
<option value='Jeep'>
<option value='Scania'>
</datalist>";
echo "<br>";
echo "<label for='vehicle_number_plate'>Vehicle Plate:</label>";
echo "<input class='text' type='text' name='vehicle_number_plate' placeholder='number plate'>";
echo "<br>";
echo "<label for= 'vehicle_description'> Vehicle Description:</label>";
echo "<input type = 'text' name = 'vehicle_description' placeholder='vehicle description' >";
echo "<br>";
echo "<br>";
echo "<label for ='vehicle_picture'> Vehicle Picture:</label>";
echo "<input class = 'tex' type = 'file' value = 'vehicle_picture' name='vehicle_picture' >";
echo "<br>";
echo "<label for ='vehicle_price'> Vehicle Price:</label>";
echo "<input type = 'text' placeholder = 'Vehicle price' name='vehicle_price' >";
echo "<br>";
echo "<label for= 'payment method'> Payment Method: </label>";
echo "<input type='text' list = 'payment_method' name = 'payment_method' placeholder='Payment Method'>";
echo "<datalist id='payment_method'>
<option value = 'Till No:'>
<option value = 'Bank Account:'>
<option value = 'Mpesa No:'>
<option value = 'Paybill No:'>
<option value = 'Cash On Delivery'>
</datalist>";
echo "<br>";
echo "<label for= 'vehicle category'> Vehicle Category: </label>";
echo "<input type='text' list = 'vehicle_category' name = 'vehicle_category' placeholder='Vehicle Category'>";
echo "<datalist id='vehicle_category'>
<option value = 'Truck'>
<option value = 'Suv'>
<option value = 'Coupe'>
<option value = 'Bus'>
<option value = 'Lorry'>
</datalist>";
echo "<br>";
echo "<label for= 'vehicle_seller'> Seller details:</label>";
echo "<input type = 'text' name = 'vehicle_seller' placeholder='Seller details' >";
echo "<br>";
echo "<br>";
echo "<input class = 'submit' type = 'submit' value='submit'style='margin-right: 16px'/>";
echo "<input class = 'submit' type ='reset' value = 'reset'>";
echo "<form/>";
echo "</div>";
?>
</body>
</html>