How to transfer music from IPhone to computer/ITunes?

I'm about to sell my laptop and deleted ITunes. Not thinking about it. Most of my music I bought from ITunes but I also "illegally" downloaded songs too. Is there any way I can just transfer all my songs onto my new computer or straight to ITunes? Thanks!

Added (1). I don't have any of the songs on the laptop either, just on my phone.

Just sinc your phone with the new computer you have

If your songs are all purchased from iTunes store, Plug in iPhone to computer, then go to iTunes menu "File-> Transfer purchases", It will copy your bought songs from iPhone to computer.
Or You may refer to this guide, it will show you the detail steps to transfer files from iPod/iPhone to computer or iTunes, including music, video, playlist, photo, etc. It's easy to understand and works pretty well for my iPhone.