I second what Cara said. When my dog was a puppy, the rule was "4 on the floor" to be petted. I honestly didn't care if she was sitting or laying down, as long as all 4 paws were on the floor. But to get there, it's easiest to start with putting them with a sit or down. The biggest challenge with this is getting other people to cooperate. I requested friends, family, complete strangers who wanted to pet her, to wait until she was sitting or at least had all 4 paws on the ground before petting her.
It has created a funny little habit for my dog. Now when we're walking or out and about, and she she's someone she wants to greet, she instantly lays down, like hits the ground (while a little wiggly and smiley). If the person wants to come up and pet her, and they usually do because they can tell how excited she is about seeing them, I let them. Sometimes the person doesn't want to so I have to coax her to keep walking with me. For a moment she'll be like.. "wait.. I wanted to say hi". I get compliments on how well behaved she is pretty often when we're out an about. She seems to know how to turn on the charm to get attention.