prepare($checkSql); $checkStmt->bindParam(':inviteCode', $inviteCode); $checkStmt->execute(); if ($checkStmt->rowCount() > 0) { $invite = $checkStmt->fetch(PDO::FETCH_ASSOC); $updateSql = "UPDATE `invitesToPassengers` SET `isInstall` = 1, `passengerID` = :passengerID WHERE `id` = :id"; $updateStmt = $con->prepare($updateSql); $updateStmt->bindParam(':id', $invite['id'], PDO::PARAM_INT); $updateStmt->bindParam(':passengerID', $passengerID); $updateStmt->execute(); if ($updateStmt->rowCount() > 0) { jsonSuccess(null, "Invite code successfully used and marked as installed."); } else { jsonError("Invite found but update failed."); } } else { jsonError("Invalid invite code, already used, or marked as gift."); } } catch (PDOException $e) { error_log("[updatePassengersInvitation.php] " . $e->getMessage()); jsonError("An internal error occurred. Please try again later."); } ?>