ignore him (no touch, no talk, no eye contact) until he settles down.
My Cocker Spaniel has the same problem! The second a new person bends down to pet her, her whole back end wiggles from side to side and she piddles all over. Sometimes the pee ends up on the persons feet!! I just tell people to ignore her at first until she calms down. Or have her sit or lay down before petting her.
How old is he? He will most likely grow out of it. Until then, ignore him upon greeting.