I've actually had similar problems, encluding what you're describing. I fixed this by puting what php file I would like to run in (I used XAMPP, which installs everything in a simple package, I'd look into that as well. PM me here and I can help you further) htdocs, or the folder in which http://127.0.0.1 is directed to. This ensures that you are using the PHP engine.
Like I said, I've had similar problems as you, and all worked fine by doing the above. And remmber, if you need help, PM me here and we can get in further contact.
-Steven Katzman