'error', 'message' => 'An unknown error occurred.']; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $data = json_decode(file_get_contents('php://input'), true); if (isset($data['companyName'], $data['contactPerson'], $data['email'], $data['phone'], $data['quantity'], $data['deliveryAddress'])) { try { $pdo = db(); $stmt = $pdo->prepare( 'INSERT INTO orders (company_name, contact_person, email, phone, quantity, delivery_address) VALUES (?, ?, ?, ?, ?, ?)' ); $stmt->execute([ $data['companyName'], $data['contactPerson'], $data['email'], $data['phone'], $data['quantity'], $data['deliveryAddress'] ]); $response['status'] = 'success'; $response['message'] = 'Your order has been placed successfully!'; } catch (PDOException $e) { $response['message'] = 'Database error: ' . $e->getMessage(); } } else { $response['message'] = 'Invalid input. Please fill out all fields.'; } } else { $response['message'] = 'Invalid request method.'; } echo json_encode($response);