<?php include("../cn.php");

$customer = $_REQUEST["id"];
$bookingno = $_REQUEST["BookingNo"];

$sql = "UPDATE rentedcars SET `status`='accepted' WHERE  `BookingNumber`='$bookingno' AND `driver_id`='$customer' AND `StartTime` is NULL ";

// $myfile = fopen("testfile.txt", "w");
// fwrite($myfile, $sql);
// fclose($myfile);

$result = mysqli_query($connect, $sql);
// $response["count"] = mysqli_affected_rows($result);

if ($result)
{
$response["code"] = "200";
$response["msg"] = "Ride Accepted Successfully";
}
else
{
    $response["code"] = "202";
    $response["msg"] = "Trip Started, Ride cannot be cancelled.";
}

echo json_encode($response);

?>