Welcome to the forum,
You would probably be better off posting in the inDesign forum.
the pages are totally messed up
You may also want to be more descriptive about what is actually happening so others can help, when posting over there.
[Moved from Cloud forum to Indesign forum]
In order for anyone to help you you'll need to provide a lot more information. Which version of ID? Is the latest patch installed? What OS?
Waht are you using to view the ePub? What does "totally messed up" mean? A real description, and maybe some screen captures, would be a big help.
If you haven't properly prepared your pages for EPUB export, it's common for them to look "totally messed up" after export.
At a minimum you need to apply paragraph and character styles consistently. Images must be anchored into your text flow or set up as inline graphics. EPUB only supports one text flow so if you have multiple flows on your pages, it won't at all look correct. You can use the Articles panel to set object export order.
I'd suggest strongly that you do some reading on EPUB file preparation. Two good sources:
(1) Elizabeth Castro's eBooks on EPUB production in InDesign:
(2) Anne-Marie Conception's Lynda.com videos on EPUB preparation for CS5, CS5.5 and CS6.