How to get iphone music back in my itunes?

I had to recover my laptop to factory settings and i installed itunes again. But this time, it won't use my phone as the default phone (i have no idea how to word this). Like, for example, if i click on music, its blank! My songs are gone! But if i click on the top right where it has my iphone, i can access my music there. But then i synced it and it had a pop up saying something like all my songs will be deleted on my phone and the songs and files on this itunes will go to my phone instead, BUT there's nothing on the new itunes i just installed! What do i do?!

Hook you iphone to your computer and sync

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.
This way is not work for the CD ripped music and website download music. But you can follow this step by step guide to transfer all the music from iPod/iPhone to iTunes, including the non-purchases songs. It's easy to understand and works pretty well for my iPhone 5.