-
Notifications
You must be signed in to change notification settings - Fork 0
/
garageowner.php
218 lines (192 loc) · 9.48 KB
/
garageowner.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
<?php
session_start();
?>
<?php
// database connection start
include 'partials\_dbconnect.php';
// database connection End
$alerterror = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$fullname = $_POST['fullname'];
$garagename = $_POST['garagename'];
$garageaddress = $_POST['garageaddress'];
$garagezip = $_POST['zipcode'];
$garagecity = $_POST['garagecity'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$licenceno = $_POST['licenceno'];
$Ownerphoto = addslashes(file_get_contents($_FILES['Ownerphoto']['tmp_name']));
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
// Form validations---------------------------------------------------------------------------------------------
$imagevalid = false;
$namevalid = false;
$garagenamevalid = false;
$passwordvalid = false;
// image validation checking=============
$allowed_image_extension = array("png","jpg","jpeg");
$file_extension = pathinfo($_FILES["Ownerphoto"]["name"], PATHINFO_EXTENSION);
if (!in_array($file_extension, $allowed_image_extension) || ($_FILES["Ownerphoto"]["size"] > 1000000)) {
$imagevalid = true;
}
//name validation=================
if (!preg_match("/^[a-zA-Z-' ]*$/", $fullname)) {
$namevalid = true;
}
//garagename validation=================
if (!preg_match("/^[a-zA-Z-' ]*$/", $garagename)) {
$garagenamevalid = true;
}
//password pattern===================
$uppercase = preg_match('@[A-Z]@', $password);
$lowercase = preg_match('@[a-z]@', $password);
$number = preg_match('@[0-9]@', $password);
$specialChars = preg_match('@[^\w]@', $password);
if (!$uppercase || !$lowercase || !$number || !$specialChars || strlen($password) < 8) {
$passwordvalid =true;
}
//form validatin End----------------------------------------------------------------------------------------------
$sql1 = "SELECT *FROM `garage_owner` WHERE `g_email` = '$email' ";
$result1 = mysqli_query($conn, $sql1);
$num1 = mysqli_num_rows($result1);
if ($num1 > 0) {
$alerterror = "E-mail is already registred please try with another E-mail.";
} else {
if ($password == $confirmpassword) {
if ($imagevalid == true || $namevalid ==true || $garagenamevalid == true || $passwordvalid ==true) {
if ($passwordvalid ==true) {
$alerterror .= '<br>- Password should be at least 8 characters in length and should include at least one upper case letter, one number, and one special character.';
}if ($namevalid ==true ) {
$alerterror .= '<br>- User name should be only in letters';
}
if ($garagenamevalid ==true ) {
$alerterror .= '<br>- Garage Owner name should be only in letters';
}
if($imagevalid == true){
$alerterror .='<br>- Upload valiid images. Only PNG,JPG and JPEG are allowed and file size should be less then 1 MB';
}
} else {
$hashpassword = password_hash($password, PASSWORD_DEFAULT);
$sql2 = "INSERT INTO `garage_owner` (`g_owner_name`, `g_name`, `g_address`, `g_zipcode`,`g_city`, `g_email`, `g_phone`, `g_licence`, `g_photo`, `g_password`) VALUES ('$fullname', '$garagename ', '$garageaddress', '$garagezip','$garagecity', '$email', '$phone', '$licenceno','$Ownerphoto','$hashpassword')";
$result2 = mysqli_query($conn, $sql2);
if ($result2) {
header("location: garage_login.php?signup=success");
}
}
} else {
$alerterror = "Confirm password can't match please enter same password in both section ";
}
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="MYMECHANIC_CSS/style.css">
<title>Mymechanic | Sign Up</title>
</head>
<body>
<!-- include navbar start -->
<?php include 'partials\_navbar.php'; ?>
<!-- include navbar End -->
<?php
if ($alerterror)
echo '<div class="alert alert-danger alert-dismissible fade show my-2 mx-2" role="alert">
<i class="bi bi-exclamation-triangle-fill" style="font-size:20px"> </i><strong>Sorry!! </strong>' . $alerterror . '
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
?>
<!-- garageowner form html start -->
<div class="form-container">
<div class="field-container">
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="customer-form" enctype="multipart/form-data">
<h2 class="form-field" style="font-weight: bold; color:white; text-align:center">Garage Owner Form <i class="bi bi-card-checklist"></i> </h2>
<hr style="height:4px; background-color: Red;">
<div class="form-field mb-3">
<p style="font-weight: bold; color:white">Enter Your Full Name: </p>
<input type="text" class="form-control" id="fullname" name="fullname" placeholder="Enter Name" maxlength="30" required="required" />
</div>
<div class="form-field mb-3">
<p style="font-weight: bold; color:white">Enter Garage Name: </p>
<input type="text" class="form-control" id="garagename" name="garagename" placeholder="Enter Garage Name" maxlength="50" required="required" />
</div>
<hr style="height:4px; background-color: white;">
<div class="form-field-merge mb-3">
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Enter zip code</p>
<input type="text" maxlength="6" class="form-control" id="zipcode" pattern="[0-9]{6}" oninvalid="this.setCustomValidity('Zip code must be 6 digits')" onchange="this.setCustomValidity('')" name="zipcode" placeholder="Ex.360 370" required="required" />
</div>
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Enter City Name:</p>
<select class="form-select " id="garagecity" name="garagecity">
<?php
$city = "SELECT *FROM `city`";
$cityresult = mysqli_query($conn, $city);
while ($cityrow = mysqli_fetch_assoc($cityresult)) {
$cityname = $cityrow['city_name'];
echo '<option value="' . $cityname . '">' . $cityname . '</option>';
}
?>
</select>
</div>
</div>
<div class="form-field-merge mb-3">
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Email:</p>
<input type="email" class="form-control mx-1" id="email" pattern=".+@gmail\.com"
oninvalid="this.setCustomValidity('Enter Valid Email it contains \'@\' or\'.\' ')"
onchange="this.setCustomValidity('')" name="email" placeholder="Enter E-Mail"
maxlength="50" required="required" />
</div>
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Mobile No:</p>
<input type="text" class="form-control" id="phone" pattern="[0-9]{10}" oninvalid="this.setCustomValidity('mobile number must be 10 digits')" onchange="this.setCustomValidity('')" name="phone" placeholder="Enter Phone Number" maxlength="10" required="required" />
</div>
</div>
<div class="form-field-merge mb-3">
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Garage Licence Number :</p>
<input type="text" class="form-control" id="licenceno" name="licenceno" placeholder=" Licence Number" maxlength="20" required="required" />
</div>
<div class="mx-2" style="width:100%">
<p style="font-weight: bold; color:white">Garage Owner photo :</p>
<input type="file" class="form-control" id="Ownerphoto" name="Ownerphoto" required="required" />
</div>
</div>
<div class="form-field mb-3">
<p style="font-weight: bold; color:white">Address :</p>
<textarea class="form-control" id="garageaddress" name="garageaddress" placeholder="Enter Garage Adress" maxlength="50" required="required"></textarea>
</div>
<hr style="height:4px; background-color: white;">
<div class="form-field mb-3">
<p style="font-weight: bold; color:white">Enter Password:</p>
<input type="password" class="form-control" id="password" name="password" maxlength="30" required="required" />
</div>
<div class="form-field mb-3 ">
<p style="font-weight: bold; color:white">Confirm Password:</p>
<input type="password" class="form-control" id="confirmpassword" name="confirmpassword" maxlength="30" required="required" />
</div>
<div class="form-field mb-3">
<input type="checkbox" class="form-check-input mx-1" id="checkterms" required="required" oninvalid="this.setCustomValidity('Please accept Terms&Condition')" onchange="this.setCustomValidity('')" />
<label class="form-check-label text-light" for="exampleCheck1">Read and accept all <a class="text-primary" href="t&c.php">Terms and Condition.</a></label>
</div>
<hr style="height:2px; background-color: Red;">
<div class="button-container">
<button class="customer-submit mb-1 " type="submit">Submit</button>
<button class="customer-submit mb-1 " type="reset">Reset</button>
</div>
</form>
</div>
</div>
<!-- garageowner form html start -->
<!-- Footer End -->
<?php include 'partials/_footer.php'; ?>
<!-- Footer End -->
<script src="MYMECHANIC_JS/mechanic.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
</html>