Thousands of students and older travellers who have booked rail tickets online may have been overcharged because of a flaw in thetrainline.com, the booking website used by all UK rail companies.

Millions of young and older rail users pay £20 for their young person's or senior citizen's railcard each year in the expectation that they will get the cheapest travel, once the 33% discount is applied. However, because of the way the website is set up, many will have paid more for their tickets than had they not used their cards at all.

The issue is exacerbated by the fact that all online bookings are routed through thetrainline.com, even if the traveller is not aware of it. Individual train companies brand the service in their colours, but it is thetrainline.com which operates the system. The company was originally owned by Virgin Trains but is now in the hands of private equity operators Exponent.

The overcharging stems from the fact that the train companies sell tickets in batches. There are only a limited number of "railcard discounted tickets" available on each train. Once the batch is sold, the railcard user is then offered the next highest railcard fare, even when there are cheaper, full fare tickets still for sale.

One recent victim, Chris Shaw, a civil engineering student, tried to buy a single ticket from his parent's Penrith home to Birmingham following the Easter break. "I started looking on thetrainline.com site over six days before I was due to travel, but every time I logged on to check the price, none of the cheap tickets were available. I wanted to use my railcard but the best fare available was a standard open single at £32.65.

"A few days later I logged on again but accidentally forgot to put in the fact that I had a railcard, and I was offered a ticket for just £19. To check I wasn't making a mistake, I went back and did it again with the card and the fare went back up to £32. I'm now wondering whether, if I'd done the search earlier without a railcard, I'd have had a greater choice of times and prices. What's the point of a railcard if it's cheaper to book without it? It's all a bit of a con," he says.

The UK's foremost expert on rail fares, travel consultant Barry Doe, says he recently brought this anomaly to the attention of the Association of Train operating Companies (ATOC), but has yet to get a response. "I would always tell anyone looking on thetrainline.com for the cheapest tickets to look first without inputting the fact that you have a railcard, and then with. You'll be surprised how many times it will be cheaper without the card. The website is very confused and needs to be sorted out," he says.

"The problem is not just limited to young people's railcards. It's the same for senior cardholders too. Most people buy and use these cards thinking they are going to get the lowest fares. The website needs to be reconfigured so that it offers the next cheapest fare, regardless of whether that involves the use of a railcard or not."

This is the latest problem to blight rail travel bookings. Last year Money revealed that long train journeys are often cheaper if you buy two tickets and travel in stages because of anomalies in what critics say is the absurdly over-complicated booking system.

A spokesman for Virgin Trains, which runs the Penrith-Birmingham line, admits that each service has a set number of railcard fares, but said we would have to talk to the ATOC and Trainline for an explanation.

An ATOC spokesman thanked Money for bringing the matter to their attention. "Chris Shaw should have been able to see the full ticket range available when he tried to book his ticket on thetrainline.com, even if a railcard discount was not available. We have now raised this issue with thetrainline and asked them to ensure their website does display the full range of fares available."

After initially denying that railcard fares could be higher than standard fares, thetrainline eventually admitted that the situation does indeed occur. It said: "The ticketing problem experienced by Mr Shaw appears to be linked to the way in which some train companies place their fares on the national reservation system which thetrainline uses. We are investigating this together with the company concerned and we will ensure that any issue is resolved as quickly as possible. As the UK's leading rail ticket retailer, thetrainline is committed to the highest quality service for all customers. We sincerely apologise for any inconvenience caused."

Meanwhile, Mr Shaw is wondering how many other students have been paying inflated prices for train tickets. "You do wonder how many people have been overcharged."

See you in court, passenger tells GNER

A Surrey businessman says GNER is going to have to sue him if it wants £256 in penalties and extra fares demanded by one of its guards who insisted he was on the wrong train.

Richard Alaoui, managing director of RRA Solutions, had bought two off-peak return tickets to Newcastle at Woking station for travel several weeks later. He and his secretary got on the return train at 1.30pm. He says that as soon as the inspector saw the tickets, he bluntly told them they could not be used on that train.

Despite his pleas that he was never told he had to be on a specific train, the guard demanded £256 in new tickets and penalties. "He was rude in the extreme, and even admitted that our tickets would not have cost any more had we been booked on that train. He was so unpleasant that my secretary burst into tears and was physically sick after we arrived at King's Cross." Mr Alaoui says he won't pay and will see GNER in court.

GNER says it is investigating the case. "It is the passenger's responsibility to travel on the right train," says a spokesman.