As above poster explained, do not put any frequent flyer number in the PNR and make sure to keep the boarding pass stubs secure and send a copy of your ticket and boarding pass for each flight segment to the airline you want your miles.
I've done this several times with a 4 segment itinerary, each flight segment going to a different airline, and I've received credit in each program. it works as long as you don't send the same segment to two different airlines, .