if ($user = $db->users()->where('email', $email)->fetch()) { $data = array('firstName' => $user['firstName'], 'lastName' => $user['lastName'], 'email' => $user['email'], 'phone1' => $user['phone1'], 'phone2' => $user['phone2'], 'address' => $user['address'], 'landmark' => $user['landmark'], 'pincode' => $user['pincode'], 'city' => $user['city'], 'state' => $user['state']); } $user = array('user_data' => $data); $app->response()->header('content-type', 'application/json'); echo json_encode($user); }); // Contact us $app->post("/shiningfloor/contactus", function () use($app, $db) { $email = $app->request()->post('email'); $name = $app->request()->post('name'); $msg = $app->request()->post('msg'); // echo $msg . $name . $email ; $time = new DateTime("now", new DateTimeZone('Asia/Kolkata')); $time = $time->format('Y-m-d H:i:s'); $query = $db->contact_us()->insert(array("name" => $name, "email" => $email, "msg" => $msg, "date" => (string) $time)); if ($query) { echo 'success'; } }); $app->post("/buildcorner/submitOrder", $authenticate_user($app), function () use($app, $db) { $array = (array) json_decode($app->request()->getBody()); $userDetails = $array['userInfo']; // print_r($userDetails); $email = $_SESSION['user']; $userId = $db->users()->where('email', $email)->fetch(); $orderDetails = $array['items']; print_r($orderDetails); $orderTotal = $array['orderTotal']; // print_r($userDetails); // print_r($orderTotal);