How to transfer my music from my iPhone to iTunes?

Using iTunes, and not a third party software.

Added (1). I DID THAT, AND IT DELETED All THE SONGS ON MY IPHONE! WTF

Plug in your iphone, it should ask if you want to sync your iphone to itunes, and click yes. It'll copy all the apps, recordings, and music from your iphone onto your itunes.

If you purchased all of the songs through itunes store, please follow these steps:
1. Open up Itunes and Click on Itunes Store
2. Once you're in the Itunes Store look to right side of the screen and you should see the word "purchased". Click purchased and you'll be sent to a purchase screen.
3. Click on "All Songs" and then it will show all the songs you've downloaded. From there you just hit the button that looks like a cloud with an arrow on it, and it will download all the songs all over again.

If you didn't purchase them through Itunes, then you'll have to download software that will strip the songs from your iPod/iPhone onto your computer. And here is a step by step guide show you how to do that.

Browse it via My Computer