Add redirect when invalid train code is passed and flash messages