On the Magic Carpet Section collect all the lives and die before the end.
Pause the game and type "ABBAABBA".
At the first title screen, type 'lamp' you will hear Aladdin say 'yeah' like he does when you get a life. You know it has worked. Start the game as usual. Press '1' to move onto the next level.
Unlimited Apples and Invincibility
At the command line instead of typing aladdin type trainer.