What kind of car? Did you only have one wheel spinning? If so, next time you're stuck in the middle of the desert like that, try pressing the brake (not all the way) and then give it some gas (all in first gear) at the same time as pressing the brake.
The other thing you want to do is to drop the air pressure in the tires. If you have one of those small air compressors, drop it very low (maybe 12PSI) but if not, then you don't want to go too low since you won't be going anywhere with flat tires obviously On a related note, it's always a good idea to carry one of those cheap air compressors in the car that plug into the cigarette lighter (I've seen them as low as $7 at Walmart).
Also, you can try to put a jack under the car, raise the wheel, and fill up under it with sand ... this might work in some cases but not if you're stuck really bad and if there is no firm place to put the jack ... carrying a piece of wood or firm base for the jack is also a good idea.
Now once you start moving, keep moving and let the momentum take you back to the road... don't try to turn too sharply and don't slow down or else you'll sink again.
.. ok ok I'll shut up now. I know it's too late now.