If you catch your cat about to spray or in the process of eliminating, pick him up and place him in a litter box. This will make it clear that this is where he should go. When uses the box, reward him with lots of loving praise and a treat. If all else fails, after meals, confine him to a small room such as the bathroom with a litter box in it. Leave him in there for a few hours or until he uses the box.
If your cat is trying to use the litter box but misses the target, try stitching to a covered or hooded type, or get a bigger box with higher sides. If it is in a corner, move it out a little so that he can maneuver better, and spread some newspapers around the outside of the box to catch any accidents.
If you have a large house, your cat might be confused about where the box is. Place a small nightlight near it, and consider putting a litter box on each floor of the house. Cats who have accidents almost always know that they are doing something they should not but they may be confused about the location of the litter box.
Older cats may be house soiling accidents because as they age, they lose muscle tone, including muscles that control the bladder. They may not be able to hold it until they get to a litter box. If your cat has arthritis, he might need to have a box with lower sides that is easier to climb on and out of.
Remember that is your cat is not using the litter box as he should; something is not right in his world. Although it is frustrating, do not give up on him. Once you do a little investigating and figure out the problem, the solution may be something as simple as buying a different brand of cat litter.