prepare( 'SELECT * FROM home_sharing WHERE idsharing = ? AND (idshareduser = ? OR shared_email = ?) LIMIT 1' ); $stmt->execute([$idsharing, $user['id'], $user['email']]); if (!$stmt->fetch()) { json_error(403, 'No access to this invitation'); } // Set status and bind the recipient if they were invited by e-mail. $pdo->prepare('UPDATE home_sharing SET status = ?, idshareduser = ? WHERE idsharing = ?') ->execute([$status, $user['id'], $idsharing]); json_ok();