false]); exit; } $stmt = $pdo->prepare("SELECT * FROM friends WHERE (from_id = ? AND to_id = ?) OR (from_id = ? AND to_id = ?)"); $stmt->execute([$from_id, $to_id, $to_id, $from_id]); if (!$stmt->fetch()) { $pdo->prepare("INSERT INTO friends (from_id, to_id, type) VALUES (?, ?, 3)") ->execute([$from_id, $to_id]); } echo json_encode(['success' => true]);