Crate training will work for a non puppy dog. I can't say my own are perfectly housetrained, I have to keep an close eye for signals of impending potty. Lavish praise and give treats when they pee outside. Never ever ever rub a dog's nose in feces or urine. All you achieve by doing that is making them fear you. If you catch them mid stream, hustle them out and when they finish, praise and treats. No flipping out, they'll seek out spaces to pee where you can't see them and stepping in cold squishy carpet is no joy.
Have patience and purchase a Bissel Green Machine.