forked from kalyanm72/Online-Bus-Booking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_passenger.php
More file actions
36 lines (31 loc) · 1.01 KB
/
Copy pathcreate_passenger.php
File metadata and controls
36 lines (31 loc) · 1.01 KB
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
<?php
header('Access-Control-Allow-Origin: *' );
header('Content-Type:application/json' );
header('Access-Control-Allow-Methods: POST ' );
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,
Access-Control-Allow-Methods,Autherization,X-Requested-with');
include_once 'Database.php';
include_once 'Post_passenger.php';
$database=new Database();
$db=$database->connect();
$routes=new Post_passenger($db);
$data=json_decode(file_get_contents("php://input"));
$result=$routes->read();
$num=$result->rowCount();
$routes_array=array();$temp;
$routes_array['data']=array();
while($row=$result->fetch(PDO::FETCH_ASSOC)){
extract($row);
if(isset($pid))
$temp=$pid+1;
}
$routes->pid=$temp;
$routes->name=$data->name;
$routes->email=$data->email;
$routes->mob=$data->mob;
if($routes->create()){
echo json_encode(array('message'=>'Passenger added successfully'));
}
else{
echo json_encode(array('message'=>'Passenger Not added'));
}