-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_location.php
38 lines (36 loc) · 1.08 KB
/
driver_location.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
<?php
include("db.php");
date_default_timezone_set("Asia/Kolkata");
if($_POST){
//print_r($_POST);
$time=date("Y-m-d H:i:s");
$driver_id=$_POST['driver_id'];
$lat=$_POST['lat'];
$lon=$_POST['lon'];
$sq=("select * from driver_location where driver_id='$driver_id'");
$s=mysql_query($sq);
if(mysql_num_rows($s)==0){
$query1= "insert into driver_location values(id,'".$time."','".$driver_id."','".$lat."','".$lon."','0')";
}
else{
$query1= "update driver_location set time='".$time."',latitude='".$lat."',longitude='".$lon."' where driver_id='".$driver_id."'";
}
//echo $query1;
$result=mysql_query($query1);
if($result){
$query2= "select * from driver_location where driver_id='$driver_id' and status='2'";
$result1=mysql_query($query2);
if(mysql_num_rows($result1)!=0){
$query3= "update driver_location set status='0' where driver_id='".$driver_id."'";
$result2=mysql_query($query3);
}
$line["status"] = "Successfully Registered";
$cusid[] = $line;
echo json_encode($cusid);
}else{
$line["status"] = "Registration Failed";
$faild[] = $line;
echo json_encode($faild);
}
}
?>