Hi there,
This will sound a lot like the previous post b/c I second what she said.
Putting my son in his crib until he calmed down always worked for me. Sometimes he fell asleep b/c he had worn himself out, which gave me a little while of peace and quiet. Now I put him in his room unitl he is ready to behave. Luckily, at almost 4, the offenses are fewer and farther between, and it takes him much less time to calm down and decide to behave.
I had to try to remain emotionless (which was VERY hard) and most of all, if you warn him once, twice at the most, and he continues to test, you must follow through. They are trying to see how far they can get. i have had to drag him out of restaurants kicking and screaming, but it's the only way they learn that bad behavior won't be tolerated.
It might be rough going for a while, but it'll get better. My son used to bang his head on the walls, floor, crib, everywhere, and it frightened me half to death. but the doc. said he'd figure out that he was only hurting himself and grow out of it, and he did! Stay strong now so that in the future you can live in peace with your child. If you don't teach him good behavior now, you'll have to deal with it forever.
Goodluck!