Funnily enough, this situation has just been on tv, in Dom on the spot.
This is right. A ticket must be bought before you get on the train.
How do you go on when the ticket machine isn't working?
This happened to us going into Brighton once. We went straight from the train to the office (without going through the barriers) to pay because we'd been unable to find someone to sell us a ticket on the train.
We got an almighty lecture about buying a ticket before travel, but they then...