-
Notifications
You must be signed in to change notification settings - Fork 1
/
updateVehicleBooking.php
159 lines (92 loc) · 3.07 KB
/
updateVehicleBooking.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
<?php
header("Content-Type: application/json; charset=UTF-8");
require 'dbconfig.php';
$table = "";
$dropdownData = "";
$bookings_id = "";
$booking_date = "";
$returnDate = "";
$userid="";
//$booking_date = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$table = isset($_POST["table"]) ? $_POST["table"] : "";
$booking_id = isset($_POST["bookings_id"]) ? $_POST["bookings_id"] : "";
// $booking_date = isset($_POST["bookings_id"]) ? $_POST["bookings_id"] : "";
$userid = isset($_POST["userid"]) ? $_POST["userid"] : "";
// print_r($ddldata);
$returnDate = isset($_POST["returnDate"]) ? $_POST["returnDate"] : "";
$passangerNumber = isset($_POST["passangerNumber"]) ? $_POST["passangerNumber"] : "";
$booking_date = isset($_POST["booking_date"]) ? $_POST["booking_date"] : "";
//
// print("return Date:");
// print_r($returnDate);
//
// print("booking date:");
//
// print_r($booking_date);
//
// print("booking id:");
// print_r($booking_id);
// exit();
$ddldata = json_decode($_POST["data"], true);
//
// print($passangerNumber);
// print($table);
// print_r($ddldata);
//
// exit();
$destination = $ddldata[1]['selectedValue'];
// print_r($ddldata[2]);
// print_r($destination);
// exit();
$car = $ddldata[2]['selectedValue'];
$pickUpLocation = $ddldata[0]['selectedValue'];
// $bookingTime=getdate();
$edited_time = date("Y-m-d");
// print($d);
// exit();
// $dropdownData=isset($_POST["data"]) ? $_POST["data"] : "";
// print($dropdownData);
// $x=json_decode(dropdownData);
// print($x);
//
// exit();
// json_encode
// print($table);
// exit();
// $uname = isset($_POST["username"]) ? $_POST["username"] : "";
// $password = isset($_POST["password"]) ? $_POST["password"] : "";
// print($table);
// exit();
// print("email: ");
// print("password: ");
// print($email);
// print($password);
//echo "username and password: ",$uname,$pass;
}
$query = "update " . $table . " set destination = $destination, carNumber= $car, bookingTime=('$booking_date'), returnTime=('$returnDate'),
pickupFrom= $pickUpLocation, passengers= $passangerNumber,userid= $userid,edited_time=('$edited_time') where bookings_id= $booking_id";
//print_r($query);
//exit();
//
// $query = "select title,description,user_id from posts where posts.id='$post_id';";
$conn = new mysqli($hn, $un, $pw, $db);
// print($query);
// exit();
if ($conn->connect_error) {
// print("At line 49");
echo json_encode(array("value" => 0, "message" => 'Connection error with database, please try again '));
// die($connection->connect_error);
}
$result = $conn->query($query);
if (!$result) {
// echo json_error('Email not found please enter valid email.');
echo json_encode(array("value" => 0, "message" => 'problem in storing info. in db'));
// die($connection->error);
} else {
echo json_encode(array("value" => 1, "message" => "Success"));
// print($myJSON);
}
$conn->close();
// $result->close();
return $result;