-
Notifications
You must be signed in to change notification settings - Fork 4
/
vehicle_adding_process.php
executable file
·66 lines (55 loc) · 1.98 KB
/
vehicle_adding_process.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
<?php
header('Content-Type: application/json');
include_once 'mysqli.php';
$error = array(); $array = array();
// connecting to database
$sql = new mysqli($server, $user, $pass, $db);
if (isset($_POST['vehicle'])) {
$VehicleType = mysqli_real_escape_string($sql, $_POST['Vtype']);
$Brand = mysqli_real_escape_string($sql, $_POST['brand']);
$VehicleNo = mysqli_real_escape_string($sql, $_POST['Vno']);
$colour = mysqli_real_escape_string($sql, $_POST['colour']);
$mobileNo = mysqli_real_escape_string($sql, $_POST['mobileNo']);
//print_r($_POST);
if(empty($VehicleType)) {
array_push($error, "Vehicle type is required");
}
if(empty($Brand)) {
array_push($error, "Vehicle brand is required");
}
if(empty($VehicleNo) ) {
array_push($error, "Vehicle reistration number is required"); //error msg username
}
if(empty($colour)) {
array_push($error, "Colour of the vehicle is required"); //error msg password
}
if(empty($password)) {
array_push($error, "Password is required");
}
if(empty($conpassword)) {
array_push($error, "Confirm password is required");
}
if($password != $conpassword) {
array_push($error, "Confim passwords do not match. Try again");
}
if(count($error) == 0) {
$encryptpass = md5($password); //encryption
$query = "INSERT INTO users (`firstname`, `lastname`, `username`, `email`, `password`, `mobileno`, `group`) VALUES ('$Firstname', '$Lastname', '$username', '$email', '$encryptpass', '$mobileNo','Customer')";
$x = mysqli_query($sql, $query);
if($x)
{
$array["result"] = "success";
$array["message"] = "Registration Successful. Please use the sign in link to login.";
goto output;
} else {
//echo mysqli_error($sql);
array_push($error, "Error adding date to the database. Try again");
}
}
} else array_push($error, "Empty Data.");
$array["result"] = "error";
$array["message"] = $error;
output:
$json = json_encode($array);
echo $json;
?>